Reputation: 768
Is there an option with bootbox
that calls a function when the user closes the dialog via the 'x' button? I did not find a documentation about this when using bootbox.dialog()
.
Are there something like this:
bootbox.dialog({
message : 'My message',
callback : function() {
// User is closin' the dialog. Come on do somethin'
}
});
I even tried close
, closing
and closeCallback
instead of callback
, but non of them worked.
Upvotes: 2
Views: 5863
Reputation: 1341
$(#yourModal).on('hidden.bs.modal', function ()
{
alert("closed");
});
Got the answer from here: Bind a function to Twitter Bootstrap Modal Close
Then you could return false to prevent closing
Upvotes: 1
Reputation: 768
I figured that it's possible to achieve that by the onEscape
option (callback
), by looking into the source code of bootbox repository
.
bootbox.dialog(function(){
message: 'My message',
onEscape: function() {
// User is closin' the dialog. Come on do somethin'
}
});
Although, this does not provide the ability of preventing the closing action. Even returning false does not seem to work.
Upvotes: 5