Javascript 它是多次打开的
我正在使用Javascript 它是多次打开的,javascript,asp.net-mvc,twitter-bootstrap,bootbox,Javascript,Asp.net Mvc,Twitter Bootstrap,Bootbox,我正在使用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
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
,包含按钮的页面是动态加载的。有时候,当我点击时,引导框会打开多次,我不知道为什么
注:当我第一次加载
PartialView
时,它工作得很好,但是当我多次加载PartialView
时,bootbox
会在按钮上多次出现。请尝试这样修改您的代码:
$('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
}
});
});