I'm using bootbox to show dialog.
If I use bootbox.confirm
, bootbox.alert
or bootbox.prompt
, when pressing escape
key or clicking outside the dialog, the dialog closed as expected
but when using bootbox.dialog
, when I click outside the dialog or pressing escape
key, the dialog doesn't close, how to make it behave as other dialog do?
var box = bootbox.dialog({ show: false, backdrop: true, animate: false, title: 'Bla', message: 'bla bla bla', buttons: { cancel: { label: 'Cancel', className: 'btn-warning' }, save: { label: 'Parse', className: 'btn-success', callback: function () { // handling with ajax return false; } } } }); box.modal('show');
Pressing the ESC key or clicking close () dismisses the dialog and invokes the callback as if the user had clicked the Cancel button. Prompt dialogs require a callback function.
This should do it. Please note this has only been tested on v3. using bootstrap 2.3.2
$(document).on('click', '.modal-backdrop', function (event) { bootbox.hideAll() });
Add an onEscape
callback function, which may have an empty body.
See docs and example.
Basic code:
bootbox.dialog({ onEscape: function() {}, // ... });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With