Browse files

Made confirm:complete event fire always, passing in result of confirm…

… dialog as data.
  • Loading branch information...
1 parent 54dc9ce commit 50c06dcc02c1b08cb7a9b4b8eced54ed685c1c93 @JangoSteve JangoSteve committed May 7, 2011
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/rails.js
View
11 src/rails.js
@@ -179,8 +179,15 @@
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) && rails.fire(element, 'confirmed'));
+ var message = element.data('confirm'),
+ answer = false, callback;
+ if (!message) { return true; }
+
+ if (rails.fire(element, 'confirm')) {
+ answer = confirm(message);
+ callback = rails.fire(element, 'confirm:complete', [answer]);
+ }
+ return answer && callback;
},
// Helper function which checks for blank inputs in a form that match the specified CSS selector

0 comments on commit 50c06dc

Please sign in to comment.