Skip to content

Instantly share code, notes, and snippets.

@tgriesser
Created October 2, 2012 13:06
Show Gist options
  • Save tgriesser/3818951 to your computer and use it in GitHub Desktop.
Save tgriesser/3818951 to your computer and use it in GitHub Desktop.
multiple nested changes with silent
this case:
test("multiple nested changes with silent", 2, function() {
var changes = [];
var model = new Backbone.Model();
model.on('change:b', function(model, val) { changes.push(val); });
model.on('change', function() {
model.set({b: 1});
model.set({b: 2}, {silent: true});
});
model.set({b: 0});
deepEqual(changes, [0, 1, 1]);
model.change();
deepEqual(changes, [0, 1, 1, 2, 1]);
});
is now:
test("multiple nested changes with silent", 2, function() {
var changes = [];
var model = new Backbone.Model();
model.on('change:b', function(model, val) { changes.push(val); });
model.on('change', function() {
model.set({b: 1});
model.set({b: 2}, {silent: true});
});
model.set({b: 0});
deepEqual(changes, [0, 1]);
model.change();
deepEqual(changes, [0, 1, 2, 1]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment