Skip to content

Commit

Permalink
set _changing = false only if !alreadyChanging
Browse files Browse the repository at this point in the history
  • Loading branch information
braddunbar committed Nov 9, 2011
1 parent f9ae1a1 commit 20a2e34
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},

Expand Down
9 changes: 9 additions & 0 deletions test/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
});

});

0 comments on commit 20a2e34

Please sign in to comment.