vendor/assets/javascripts/jquery.remotipart.js in remotipart-1.0.2 vs vendor/assets/javascripts/jquery.remotipart.js in remotipart-1.0.3
- old
+ new
@@ -18,10 +18,19 @@
delete settings.beforeSend;
settings.iframe = true;
settings.files = $($.rails.fileInputSelector, form);
settings.data = form.serializeArray();
+
+ // 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--)
+ if (settings.data[j].name == file.name)
+ settings.data.splice(j, 1);
+ })
+
settings.processData = false;
// Modify some settings to integrate JS request with rails helpers and middleware
if (settings.dataType === undefined) { settings.dataType = 'script *'; }
settings.data.push({name: 'remotipart_submitted', value: true});
@@ -49,10 +58,10 @@
.unbind('ajax:beforeSend.remotipart')
.removeData('remotipartSubmitted')
}
};
- $('form').live('ajax:aborted:file', function(){
+ $(document).on('ajax:aborted:file', 'form', function(){
var form = $(this);
remotipart.setup(form);
// If browser does not support submit bubbling, then this live-binding will be called before direct