Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force close of bootbox.alert() on an outside of modal click?

Tags:

bootbox

How to force close of bootbox.alert() on an outside of modal click? Ideally without jQuery.

I am using Bootbox v4.4.0.

like image 327
kiriz Avatar asked Oct 25 '25 13:10

kiriz


1 Answers

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.

like image 185
Tieson T. Avatar answered Oct 27 '25 10:10

Tieson T.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!