javascript - Ask if user really want to close bootstrap modal - Stack Overflow

I have a bootstrap modal. When it is closed some instructions are executed. But now I want to ask if us

I have a bootstrap modal. When it is closed some instructions are executed. But now I want to ask if user really want to close it (with a confirm window) What can i do?

Here is my code at the moment.

$('#modal').on("hide.bs.modal", function (e) {
    //Instructions to execute when the modal is closed
});

I have a bootstrap modal. When it is closed some instructions are executed. But now I want to ask if user really want to close it (with a confirm window) What can i do?

Here is my code at the moment.

$('#modal').on("hide.bs.modal", function (e) {
    //Instructions to execute when the modal is closed
});
Share Improve this question asked Mar 1, 2016 at 5:15 Pablo De LucaPablo De Luca 8233 gold badges16 silver badges31 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

Like this?

$('#modal').on("hide.bs.modal", function (e) {
   if(confirm("Are you sure, you want to close?")) return true;
   else return false;
});

Or, just like this:

$('#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;
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745503466a4630521.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信