mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Fix #1112 - options.model sets collection.model.
This commit is contained in:
@@ -512,6 +512,7 @@
|
||||
// its models in sort order, as they're added and removed.
|
||||
var Collection = Backbone.Collection = function(models, options) {
|
||||
options || (options = {});
|
||||
if (options.model) this.model = options.model;
|
||||
if (options.comparator) this.comparator = options.comparator;
|
||||
this._reset();
|
||||
this.initialize.apply(this, arguments);
|
||||
|
||||
@@ -528,4 +528,11 @@ $(document).ready(function() {
|
||||
ok(c.get() === undefined);
|
||||
});
|
||||
|
||||
test("#1112 - passing options.model sets collection.model", function() {
|
||||
var Model = Backbone.Model.extend({})
|
||||
var c = new Backbone.Collection([{id: 1}], {model: Model});
|
||||
ok(c.model === Model);
|
||||
ok(c.at(0) instanceof Model);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user