Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

save with non-model success

  • Loading branch information...
commit c396adb2dde5265a6a76e8affc75d5bf47d0ab4a 1 parent a24544b
@tgriesser tgriesser authored
Showing with 13 additions and 1 deletion.
  1. +1 −1  backbone.js
  2. +12 −0 test/model.js
View
2  backbone.js
@@ -461,7 +461,7 @@
model.attributes = attributes;
var serverAttrs = model.parse(resp, options);
if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs);
- if (!model.set(serverAttrs, options)) return false;
+ if (typeof serverAttrs === 'object' && !model.set(serverAttrs, options)) return false;
if (success) success(model, resp, options);
};
View
12 test/model.js
@@ -423,6 +423,18 @@ $(document).ready(function() {
equal(model.get('title'), 'Twelfth Night');
});
+ test("save with non-object success response", 1, function () {
+ var model = new Backbone.Model();
+ model.sync = function(method, model, options) {
+ options.success(model, '', options);
+ };
+ model.save({testing:'empty'}, {
+ success: function (model) {
+ deepEqual(model.attributes, {testing:'empty'});
+ }
+ });
+ });
+
test("fetch", 2, function() {
doc.fetch();
equal(this.syncArgs.method, 'read');
Please sign in to comment.
Something went wrong with that request. Please try again.