Merge pull request #736 from braddunbar/nested-set

Multiple nested calls to set
This commit is contained in:
Jeremy Ashkenas
2011-11-09 11:04:46 -08:00
2 changed files with 13 additions and 2 deletions

View File

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

View File

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