An old question, but if you want to add confirmation dialogs for various closing actions, add this to your modal instance controller:
$scope.$on('modal.closing', function(event, reason, closed) { console.log('modal.closing: ' + (closed ? 'close' : 'dismiss') + '(' + reason + ')'); var message = "You are about to leave the edit view. Uncaught reason. Are you sure?"; switch (reason){ // clicked outside case "backdrop click": message = "Any changes will be lost, are you sure?"; break; // cancel button case "cancel": message = "Any changes will be lost, are you sure?"; break; // escape key case "escape key press": message = "Any changes will be lost, are you sure?"; break; } if (!confirm(message)) { event.preventDefault(); } });
I have a close button in the upper right corner of mine, which triggers the cancel action. Clicking on the background (if enabled) triggers the undo action. You can use this to use different messages for different closing events.
Tiago Mar 16 '16 at 11:45 2016-03-16 11:45
source share