Pab*_*uca 2 javascript confirm modal-dialog hide twitter-bootstrap-3
我有一个引导模式。当它关闭时,将执行一些指令。但是现在我想问用户是否真的想关闭它(带有确认窗口)我该怎么办?
这是我目前的代码。
$('#modal').on("hide.bs.modal", function (e) {
//Instructions to execute when the modal is closed
});
Run Code Online (Sandbox Code Playgroud)
像这样?
$('#modal').on("hide.bs.modal", function (e) {
if(confirm("Are you sure, you want to close?")) return true;
else return false;
});
Run Code Online (Sandbox Code Playgroud)
或者,就像这样:
$('#modal').on("hide.bs.modal", function (e) {
if(!confirm("Are you sure, you want to close?")) return false;
});
Run Code Online (Sandbox Code Playgroud)