gpt4 book ai didi

c# - 在导航栏中显示模态

转载 作者:太空宇宙 更新时间:2023-11-03 23:14:09 25 4
gpt4 key购买 nike

我有导航栏,如果我点击一个元素,我想在其中显示模态。标题

所以现在我在 js menupopulator 中显示我的导航栏,如下所示:

 function completeMenu(data, target) {
var prefix = "<ul class='nav navbar-nav navbar-right'>";
var sufix = "</ul>";
var items = data.d.results;
var menu = "";
for (var item in items) {
if(items[item].Funcion != null && items[item].Funcion != ""){
menu += "<li><a href=" + items[item].Enlace + " id='"+items[item].Funcion+"'>" + items[item].Title + "</a></li><li class='divider-vertical'></li>";
}
else
menu += "<li><a href=" + items[item].Enlace + ">" + items[item].Title + "</a></li><li class='divider-vertical'></li>";

所以我想要的是 items[item].Title is == SignIn show modal 而不是打开另一个链接...我可以这样做吗?

我尝试这样的事情:

for (var item in items) {
if(items[item].Funcion != null && items[item].Funcion != ""){
menu += "<li><a href=" + items[item].Enlace + " id='"+items[item].Funcion+"'>" + items[item].Title + "</a></li><li class='divider-vertical'></li>";
}
else
menu += "<li><a href=" + items[item].Enlace + ">" + items[item].Title + "</a></li><li class='divider-vertical'></li>";

if(items[item].Title == "SignIn"){
menu += "<li><a href="#mymodal" data-toggle="modal" data-target="#mymodal"></a></li>"
}
}

}

但我不想显示按钮,我想显示像我的 menupopulator 这样的 href

然后在 View 中:

<div id="mymodal" class="fade modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" >
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">
<asp:Label runat="server" ID="lblHeader"></asp:Label></h4>
</div>
<div class="modal-body">
<p>Test modal</p>
</div>

</div>
</div>

------------------------更新---------------- ----------

有我的更改,但是当我更改它时,我只得到一个标签,上面写着“true”

 function completeMenu(data, target) {
var prefix = "<ul class='nav navbar-nav navbar-right'>";
var sufix = "</ul>";
var items = data.d.results;
var menu = "";
for (item in items) {
menu += "<li><a href=" + items[item].Enlace + ">" + items[item].Title + "</a></li><li class='divider-vertical'></li>";
if(items[item].Title == "SignUp"){
menu += "<button type= button class=btn btn-link data-toggle= modal data-target=#mymodal">""
}
}

$(target).html(prefix + menu + sufix);
}

最佳答案

据我了解,您还需要更改此行:

"<button type= button class=btn btn-default data-toggle= modal  data-target=#mymodal">

给这个:

"<button type= button class=btn btn-link data-toggle= modal  data-target=#mymodal">

关于c# - 在导航栏中显示模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37862509/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com