diff --git a/backbone.js b/backbone.js index 41bdfbc2..69ce1168 100644 --- a/backbone.js +++ b/backbone.js @@ -211,8 +211,10 @@ } // Fire the `"change"` event, if the model has been changed. - if (!alreadyChanging && !options.silent && this._changed) this.change(options); - this._changing = false; + if (!alreadyChanging) { + if (!options.silent && this._changed) this.change(options); + this._changing = false; + } return this; }, diff --git a/test/model.js b/test/model.js index c76e389f..4963248b 100644 --- a/test/model.js +++ b/test/model.js @@ -449,4 +449,13 @@ $(document).ready(function() { a.set({state: 'hello'}); }); + test("Model: Multiple nested calls to set", function() { + var model = new Backbone.Model({}); + model.bind('change', function() { + model.set({b: 1}); + model.set({a: 1}); + }) + .set({a: 1}); + }); + });