diff --git a/backbone.js b/backbone.js index 87560cde..7c0ccfd8 100644 --- a/backbone.js +++ b/backbone.js @@ -107,12 +107,12 @@ // Create a new model, with defined attributes. A client id (`cid`) // is automatically generated and assigned for you. - Backbone.Model = function(attributes) { + Backbone.Model = function(attributes, options) { this.attributes = {}; this.cid = _.uniqueId('c'); this.set(attributes || {}, {silent : true}); this._previousAttributes = _.clone(this.attributes); - if (this.initialize) this.initialize(attributes); + if (this.initialize) this.initialize(attributes, options); }; // Attach all inheritable methods to the Model prototype. diff --git a/test/model.js b/test/model.js index 04cfa900..312a6f32 100644 --- a/test/model.js +++ b/test/model.js @@ -38,6 +38,16 @@ $(document).ready(function() { equals(model.one, 1); }); + test("Model: initialize with attributes and options", function() { + var Model = Backbone.Model.extend({ + initialize: function(attributes, options) { + this.one = options.one; + } + }); + var model = new Model({}, {one: 1}); + equals(model.one, 1); + }); + test("Model: url", function() { equals(doc.url(), '/collection/1-the-tempest'); doc.collection = null;