Permalink
Browse files

Merge pull request #155 from lailsonbm/master

Fire event 'confirmed' after user confirmation
  • Loading branch information...
2 parents a634e75 + 23aaf09 commit 54dc9ce0c15617c67f81a707a2de583e96eafac4 @JangoSteve JangoSteve committed May 8, 2011
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/rails.js
View
@@ -171,11 +171,16 @@
});
},
- // If message provided in 'data-confirm' attribute, fires `confirm` event and returns result of confirm dialog.
- // Attaching a handler to the element's `confirm` event that returns false cancels the confirm dialog.
+ /* If message provided in 'data-confirm' attribute:
+ - fires `confirm` event
+ - shows the confirm dialog
+ - fires the `confirmed` event
+ and returns true if no function stopped the chain and user chose yes; false otherwise.
+ Attaching a handler to the element's `confirm` event that returns false cancels the confirm dialog.
+ */
allowAction: function(element) {
var message = element.data('confirm');
- return !message || (rails.fire(element, 'confirm') && confirm(message));
+ return !message || (rails.fire(element, 'confirm') && confirm(message) && rails.fire(element, 'confirmed'));
},
// Helper function which checks for blank inputs in a form that match the specified CSS selector

0 comments on commit 54dc9ce

Please sign in to comment.