Browse files

Merge pull request #51 from pgherveou/master

handle escape event for confirmation dialogs
  • Loading branch information...
2 parents c1737db + c7643af commit f9903c8effcc3192a46b9b95f2d23b55f8ccce22 @tj tj committed Jul 6, 2012
Showing with 6 additions and 2 deletions.
  1. +5 −1 lib/components/confirmation/confirmation.js
  2. +1 −1 lib/components/dialog/dialog.js
View
6 lib/components/confirmation/confirmation.js
@@ -1,4 +1,3 @@
-
/**
* Expose `Confirmation`.
*/
@@ -117,6 +116,11 @@ Confirmation.prototype.render = function(options){
self.callback(false);
});
+ this.on('escape', function(){
+ self.emit('cancel');
+ self.callback(false);
+ });
+
actions.find('.cancel').click(function(e){
e.preventDefault();
self.emit('cancel');
View
2 lib/components/dialog/dialog.js
@@ -1,4 +1,3 @@
-
/**
* Active dialog.
*/
@@ -165,6 +164,7 @@ Dialog.prototype.escapable = function(){
$(document).bind('keydown.dialog', function(e){
if (27 != e.which) return;
$(this).unbind('keydown.dialog');
+ self.emit('escape');
self.hide();
});
};

0 comments on commit f9903c8

Please sign in to comment.