Allowing a collection to be passed into a model via the options.

This commit is contained in:
Jeremy Ashkenas
2010-11-04 23:45:48 -04:00
parent 771b87f17c
commit ece51d2383
2 changed files with 3 additions and 1 deletions

View File

@@ -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);
};

View File

@@ -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() {