set _changing = false only if !alreadyChanging

This commit is contained in:
Brad Dunbar
2011-11-09 13:56:43 -05:00
parent f9ae1a1686
commit 20a2e3408a
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});
});
});