I have several bootstrap modals in my application. when there is a modal and I pressed backspace key the popup never closes instead the back portion of web page navigates last history page visited. How can I make the bootstrap modal close when backspace is pressed?
Asked
Active
Viewed 1,631 times
0
-
This answer might be useful: http://stackoverflow.com/questions/11112127/prevent-backspace-from-navigating-back-with-jquery-like-googles-homepage – dlane Feb 12 '14 at 14:00
2 Answers
1
The bootstrap issue 2908 reports this behavior.
For angular.js one solution could be dismiss the window on $routeChangeSuccess, this way:
$rootScope.$on('$routeChangeSuccess', function() {
$modalInstance.dismiss('cancel');
});
It could also be implemented as an directive or it could be registered as a global behaviour.

Community
- 1
- 1

Filipe Costa
- 26
- 1
- 3
0
I added the function in ui-bootstrap. This way it takes the backspace event and closes the modal
case 8:
B.value.keyboard && (a.preventDefault (), and. $ Apply (function {) {
Z.dismiss (b.key, "backspace key press")
}));
Break;