gpt4 book ai didi

javascript - MVC Bootstrap 通过 jquery 设置数据切换 ="modal"

转载 作者:行者123 更新时间:2023-12-01 03:45:11 25 4
gpt4 key购买 nike

我正在使用 Bootstrap 应用程序开发 MVC。我正在通过 Jquery 调用 Bootstrap 弹出窗口。

这是我的电话

  <div style="float:left;width:100%;height:30px;" class="Sees">
<img class="btnNuevoMsg" src="~/Content/Images/NuevoMsg.png" onclick="New()" />
</div>

在 New() 函数上我做了一些验证。根据此验证,我可以重定向到另一个 View ,或者调用返回部分 View 的 Controller 方法,我将其在 Bootstrap 标记中呈现。

这是我的 Bootstrap 标签。

<div class="modal fade" id="myModalLog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

</div>

我的Jquery函数是这样的。

 $.ajax(
{
type: "POST",
url: '@Url.Action("ShowLogUser","Home")',
//data: { search: _search },
success: function (result) {
$('#myModalLog').html(result);
$('#myModalLog').modal();
// $('#myModalLog').modal('toggle');
// $('#myModalLog').modal('show');
},
error: function (req, status, error) {

}
});

效果很好...

我发现的问题是我无法使用

data-toggle="modal"

通过 Jquery...

当用户在窗口外部单击时,我不想关闭弹出窗口。

我尝试使用 $('#myModalLog').modal('toggle'); 如示例中所示,但它不起作用。

如何在 Jquery 中使用该属性?

谢谢

最佳答案

像这样向模型添加背景属性

$("#myModalLog").modal({backdrop: "static"});

这里是例子

https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_ref_js_modal_backdrop&stacked=h

关于javascript - MVC Bootstrap 通过 jquery 设置数据切换 ="modal",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43615646/

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