模态它被多次打开
Modal it is open multiple times
我正在使用 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
点击。
请尝试像这样修改您的代码:
$('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
}
});
});
我正在使用 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
点击。
请尝试像这样修改您的代码:
$('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
}
});
});