mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Merge pull request #1021 from ahamid/reset_passes_options
small patch to allow passing options through reset to model initializer
This commit is contained in:
@@ -440,6 +440,20 @@ $(document).ready(function() {
|
||||
ok(_.isEqual(col.last().attributes, d.attributes));
|
||||
});
|
||||
|
||||
test("Collection: reset passes caller options", function() {
|
||||
var Model = Backbone.Model.extend({
|
||||
initialize: function(attrs, options) {
|
||||
this.model_parameter = options.model_parameter;
|
||||
}
|
||||
});
|
||||
var col = new (Backbone.Collection.extend({ model: Model }))();
|
||||
col.reset([{ astring: "green", anumber: 1 }, { astring: "blue", anumber: 2 }], { model_parameter: 'model parameter' });
|
||||
equal(col.length, 2);
|
||||
col.each(function(model) {
|
||||
equal(model.model_parameter, 'model parameter');
|
||||
});
|
||||
});
|
||||
|
||||
test("Collection: trigger custom events on models", function() {
|
||||
var fired = null;
|
||||
a.bind("custom", function() { fired = true; });
|
||||
|
||||
Reference in New Issue
Block a user