Fixing Collection#create success callback, passing the model parameter through.

This commit is contained in:
Jeremy Ashkenas
2010-10-20 14:57:40 -04:00
parent 089fd5c1a2
commit 931338ea14

View File

@@ -417,10 +417,10 @@
create : function(model, options) {
options || (options = {});
if (!(model instanceof Backbone.Model)) model = new this.model(model);
model.collection = this;
var success = function(resp) {
model.collection.add(model);
if (options.success) options.success(model, resp);
var coll = model.collection = this;
var success = function(nextModel, resp) {
coll.add(nextModel);
if (options.success) options.success(nextModel, resp);
};
return model.save(null, {success : success, error : options.error});
},