Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -871,16 +871,17 @@
// wait for the server to agree.
create: function(model, options) {
options = options ? _.clone(options) : {};
if (!(model = this._prepareModel(model, options))) return false;
if (!options.wait) this.add(model, options);
if (!(model = this._prepareModel(model, options))) return Backbone.Deferred.reject();
if (!options.wait) model = this.add(model, options);
var collection = this;
var success = options.success;
options.success = function(resp) {
if (options.wait) collection.add(model, options);
if (options.wait) model = collection.add(model, options);
if (success) success(model, resp, options);
};
model.save(null, options);
return model;
return model.save(null, options).then(function() {
return model;
});
},

// **parse** converts a response into a list of models to be added to the
Expand Down