vendor/assets/javascripts/jquery.remotipart.js in remotipart-1.1.0 vs vendor/assets/javascripts/jquery.remotipart.js in remotipart-1.1.1

- old
+ new

@@ -6,10 +6,13 @@ var remotipart; $.remotipart = remotipart = { setup: function(form) { + // Preserve form.data('ujs:submit-button') before it gets nulled by $.ajax.handleRemote + var button = form.data('ujs:submit-button'); + form // Allow setup part of $.rails.handleRemote to setup remote settings before canceling default remote handler // This is required in order to change the remote settings using the form details .one('ajax:beforeSend.remotipart', function(e, xhr, settings){ // Delete the beforeSend bindings, since we're about to re-submit via ajaxSubmit with the beforeSubmit @@ -18,9 +21,13 @@ delete settings.beforeSend; settings.iframe = true; settings.files = $($.rails.fileInputSelector, form); settings.data = form.serializeArray(); + + // Insert the name/value of the clicked submit button, if any + if (button) + settings.data.push(button); // jQuery 1.9 serializeArray() contains input:file entries // so exclude them from settings.data, otherwise files will not be sent settings.files.each(function(i, file){ for (var j = settings.data.length - 1; j >= 0; j--)