diff --git a/src/rails.js b/src/rails.js index 86cfee1e..bc9fceb3 100644 --- a/src/rails.js +++ b/src/rails.js @@ -115,7 +115,7 @@ if (element.is('form')) { method = element.data('ujs:submit-button-formmethod') || element.attr('method'); url = element.data('ujs:submit-button-formaction') || element.attr('action'); - data = $(element[0].elements).serializeArray(); + data = $(element[0]).serializeArray(); // memoized value from clicked submit button var button = element.data('ujs:submit-button'); if (button) { diff --git a/test/public/test/data-remote.js b/test/public/test/data-remote.js index d4dc0955..e751c8e0 100644 --- a/test/public/test/data-remote.js +++ b/test/public/test/data-remote.js @@ -155,6 +155,21 @@ asyncTest('submitting form with data-remote attribute', 4, function() { .trigger('submit'); }); +asyncTest('submitting form with data-remote attribute should include inputs in a fieldset only once', 3, function() { + $('form[data-remote]') + .append('
') + .bind('ajax:success', function(e, data, status, xhr) { + App.assertCallbackInvoked('ajax:success'); + equal(data.params.items.length, 1, 'ajax arguments should only have the item once') + App.assertPostRequest(data); + }) + .bind('ajax:complete', function() { + $('form[data-remote], fieldset').remove() + start() + }) + .trigger('submit'); +}); + asyncTest('submitting form with data-remote attribute submits input with matching [form] attribute', 5, function() { $('#qunit-fixture') .append($(''));