【问题标题】:Modal it is open multiple times模态它多次打开
【发布时间】:2017-05-04 14:40:58
【问题描述】:

我正在使用bootbox 库。我有一个名为Delete 的按钮。

$('body').on("click", ".deleteDiagnostic", function () {
        var id = $(this).attr("data-diagnosticID");
        var currentRow = $(this).closest('tr');
        bootbox.confirm("Are you sure want to delete?", function (result) {
            if (result == true) {
                //code here
            }
        });
});

我也在使用PartialView,并且包含按钮的页面是动态加载的。有时我点击时,bootbox多次打开,我不知道为什么。

PS:当我第一次加载PartialView 时,它工作得很好,但是当我多次加载PartialView 时,bootbox 在点击button 时出现多次。

【问题讨论】:

    标签: javascript asp.net-mvc twitter-bootstrap bootbox


    【解决方案1】:

    请尝试像这样修改您的代码:

    $('body').on("click", ".deleteDiagnostic", function (evt) {
        evt.stopImmediatePropagation();
    
        var id = $(this).attr("data-diagnosticID");
        var currentRow = $(this).closest('tr');
        bootbox.confirm("Are you sure want to delete?", function (result) {
            if (result == true) {
                //code here
            }
        });
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-11
      • 2023-02-10
      • 1970-01-01
      • 1970-01-01
      • 2020-06-04
      相关资源
      最近更新 更多