Skip to content

Instantly share code, notes, and snippets.

@ivzhao
Created August 4, 2011 07:46
Show Gist options
  • Save ivzhao/1124673 to your computer and use it in GitHub Desktop.
Save ivzhao/1124673 to your computer and use it in GitHub Desktop.
Backbone.Collection bug?
_prepareModel: function(model, options) {
if (!(model instanceof Backbone.Model)) {
var attrs = model;
// Bug? Do we forget to pass in options here?
model = new this.model(attrs, {collection: this});
// Proposed Fix:
//model = new this.model(attrs, _.extend(options, {collection: this}));
if (model.validate && !model._performValidation(attrs, options)) model = false;
} else if (!model.collection) {
model.collection = this;
}
return model;
},
model = new this.model(attrs, _.extend(options, {collection: this}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment