Update backbone-model-file-upload.js

Fix some updates to the "formData" logic
This commit is contained in:
Joe Vu 2014-03-18 13:21:16 -07:00
parent fab16122b4
commit ec209ecf95

View File

@ -40,10 +40,11 @@
this.attributes = _.extend({}, attributes, attrs); this.attributes = _.extend({}, attributes, attrs);
} }
// Check for "allowFormData" flag and if file exist and if so, convert to FormData // Check for "formData" flag and check for if file exist.
if ( options.allowFormData !== false if ( options.formData === true
&& this.attributes[ this.fileAttribute ] || options.formData !== false
&& this.attributes[ this.fileAttribute ] instanceof File ) { && this.attributes[ this.fileAttribute ]
&& this.attributes[ this.fileAttribute ] instanceof File ) {
// Flatten Attributes reapplying File Object // Flatten Attributes reapplying File Object
var formAttrs = _.clone( this.attributes ), var formAttrs = _.clone( this.attributes ),
@ -113,4 +114,4 @@
}); });
}(_, Backbone); }(_, Backbone);