You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is how it's supposed to behave. You're notified when a model you're observing changes id, and can even listen for "change:id" events. Having the id be treated specially and being set as a direct property of the model object is a convenience:
So, after looking into it more, that's not the problem. I have no problem with id behaving that way. When I got an unexpected change event and then saw the id listed in attributes I assumed it was a mistake. But, I just hadn't noticed before.
The real problem is that this test fails:
test("Model: change event bug", function () {
var changed = 0;
var attrs = {id: 1, label: 'c'};
var obj = new Backbone.Model(attrs);
obj.bind('change', function() { changed += 1; });
obj.set(attrs);
equals(changed, 0);
});
Nothing should have changed — yet, I got a change event. Also, if inside the change callback you call changedAttributes() you get false.
The title says it all. This is also a problem because it can incorrectly trigger a 'change' event.
The text was updated successfully, but these errors were encountered: