询问用户是否真的想关闭 bootstrap 模态
Ask if user really want to close bootstrap modal
我有一个 bootstrap 模式。当它关闭时,一些指令被执行。但是现在我想问问用户是否真的想关闭它(确认window)我能做什么?
这是我现在的代码。
$('#modal').on("hide.bs.modal", function (e) {
//Instructions to execute when the modal is closed
});
像这样?
$('#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;
});
$('#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;
});
我有一个 bootstrap 模式。当它关闭时,一些指令被执行。但是现在我想问问用户是否真的想关闭它(确认window)我能做什么?
这是我现在的代码。
$('#modal').on("hide.bs.modal", function (e) {
//Instructions to execute when the modal is closed
});
像这样?
$('#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;
});
$('#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;
});