Reputation: 675
How to force close of bootbox.alert() on an outside of modal click? Ideally without jQuery.
I am using Bootbox v4.4.0.
Upvotes: 4
Views: 3692
Reputation: 21231
You can specify this behavior when creating your alert, using the backdrop
option.
Example:
bootbox.alert({
message: 'This is an alert!',
backdrop: true
})
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js"></script>
The default for that option is null
, which means clicking on the backdrop does nothing. Passing false
removes the backdrop, and passing true
shows the backdrop and makes clicking on it dismiss the dialog.
Upvotes: 7