diff options
author | Brant Burnett <btburnett3@gmail.com> | 2010-02-22 18:39:12 +0000 |
---|---|---|
committer | Brant Burnett <btburnett3@gmail.com> | 2010-02-22 18:39:12 +0000 |
commit | 350853179fc873a2afe6e8d2338a6b9e35303c9c (patch) | |
tree | 3cc0548c560a55dcbcaca217723cc21f6edcacde | |
parent | e2202847c6a8837bb732cc21401915b82e433c50 (diff) | |
download | jquery-ui-350853179fc873a2afe6e8d2338a6b9e35303c9c.tar.gz jquery-ui-350853179fc873a2afe6e8d2338a6b9e35303c9c.zip |
Dialog: ESC key event was not being canceled after it was handled (Fixed #4922 window.location.reload() doesn't work in dialog's close callback when it's triggered by ESC in Firefox)
-rw-r--r-- | ui/jquery.ui.dialog.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 6d13935de..0d48c1cf7 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -66,8 +66,12 @@ $.widget("ui.dialog", { // setting tabIndex makes the div focusable // setting outline to 0 prevents a border on focus in Mozilla .attr('tabIndex', -1).css('outline', 0).keydown(function(event) { - (options.closeOnEscape && event.keyCode - && event.keyCode == $.ui.keyCode.ESCAPE && self.close(event)); + if (options.closeOnEscape && event.keyCode + && event.keyCode == $.ui.keyCode.ESCAPE) { + + self.close(event); + event.preventDefault(); + } }) .attr({ role: 'dialog', @@ -614,8 +618,12 @@ $.extend($.ui.dialog.overlay, { // allow closing by pressing the escape key $(document).bind('keydown.dialog-overlay', function(event) { - (dialog.options.closeOnEscape && event.keyCode - && event.keyCode == $.ui.keyCode.ESCAPE && dialog.close(event)); + if (dialog.options.closeOnEscape && event.keyCode + && event.keyCode == $.ui.keyCode.ESCAPE) { + + dialog.close(event); + event.preventDefault(); + } }); // handle window resize |