Permalink
Browse files

Fixed manually-triggered form submit bindings to pass event for IE. C…

…loses #222.
  • Loading branch information...
1 parent 17f4004 commit 8a5746631a96ded8a81a76218a8286a544c012cd @JangoSteve JangoSteve committed Nov 18, 2011
Showing with 6 additions and 5 deletions.
  1. +3 −3 src/rails.js
  2. +3 −2 test/public/test/data-remote.js
View
@@ -252,11 +252,11 @@
// find all the submit events directly bound to the form and
// manually invoke them. If anyone returns false then stop the loop
- callFormSubmitBindings: function(form) {
+ callFormSubmitBindings: function(form, event) {
var events = form.data('events'), continuePropagation = true;
if (events !== undefined && events['submit'] !== undefined) {
$.each(events['submit'], function(i, obj){
- if (typeof obj.handler === 'function') return continuePropagation = obj.handler(obj.data);
+ if (typeof obj.handler === 'function') return continuePropagation = obj.handler(event);
});
}
return continuePropagation;
@@ -335,7 +335,7 @@
// If browser does not support submit bubbling, then this live-binding will be called before direct
// bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
- if (!$.support.submitBubbles && rails.callFormSubmitBindings(form) === false) return rails.stopEverything(e);
+ if (!$.support.submitBubbles && rails.callFormSubmitBindings(form, e) === false) return rails.stopEverything(e);
rails.handleRemote(form);
return false;
@@ -116,14 +116,15 @@ asyncTest('submitting form with data-remote attribute', 4, function() {
.trigger('submit');
});
-asyncTest('form\'s submit bindings in browsers that don\'t support submit bubbling', 4, function() {
+asyncTest('form\'s submit bindings in browsers that don\'t support submit bubbling', 5, function() {
var form = $('form[data-remote]'), directBindingCalled = false;
ok(!directBindingCalled, 'nothing is called');
form
.append($('<input type="submit" />'))
- .bind('submit', function(){
+ .bind('submit', function(event){
+ ok(event.type == 'submit', 'submit event handlers are called with submit event');
ok(true, 'binding handler is called');
directBindingCalled = true;
})

0 comments on commit 8a57466

Please sign in to comment.