我有一个自举模式。当它关闭时,执行一些指令。但现在我想询问用户是否真的要关闭它(带有确认窗口)我该怎么办?
这是我目前的代码。
$('#modal').on("hide.bs.modal", function (e) {
//Instructions to execute when the modal is closed
});
答案 0 :(得分:2)
喜欢这个吗?
$('#modal').on("hide.bs.modal", function (e) {
if(confirm("Are you sure, you want to close?")) return true;
else return false;
});
或者,就像这样:
$('#modal').on("hide.bs.modal", function (e) {
if(!confirm("Are you sure, you want to close?")) return false;
});
答案 1 :(得分:0)
$('#modal').on("hide.bs.modal", function (e) {
//Instructions to execute when the modal is closed
if(!confirm("Are you sure, you want to close?")) return false;
});