twitter/bootstrap — pull request #2734 by romanych (2012-03-22 09:08:07+00:00)
Title: Allow to cancel modal hiding in `hide` event handler.

In case you show form in modal you might want to add confirmation on close button click. It is very easy to do:

$('#myModal').on('hide', function() {
if (!saveButtonClicked && hasChanges) {
return false;
}
});

or

$('#myModal').on('hide', function(e) {
if (!saveButtonClicked && hasChanges) {
e.preventDefault();
}
});