mirror of
https://github.com/jashkenas/backbone.git
synced 2026-01-23 05:48:10 -05:00
Allowing a collection to be passed into a model via the options.
This commit is contained in:
@@ -112,6 +112,7 @@
|
||||
this.cid = _.uniqueId('c');
|
||||
this.set(attributes || {}, {silent : true});
|
||||
this._previousAttributes = _.clone(this.attributes);
|
||||
if (options && options.collection) this.collection = options.collection;
|
||||
if (this.initialize) this.initialize(attributes, options);
|
||||
};
|
||||
|
||||
|
||||
@@ -34,8 +34,9 @@ $(document).ready(function() {
|
||||
this.one = 1;
|
||||
}
|
||||
});
|
||||
var model = new Model;
|
||||
var model = new Model({}, {collection: collection});
|
||||
equals(model.one, 1);
|
||||
equals(model.collection, collection);
|
||||
});
|
||||
|
||||
test("Model: initialize with attributes and options", function() {
|
||||
|
||||
Reference in New Issue
Block a user