I am trying to get a view in Backbone.jsto save when there is a "change" event if (and only if) the data has changed.
In short, I have a "change" event that appears in the view that triggers this:
function changed_event() {
log.debug("Before: " + this.model.get('name'))
this.model.set({'name': 'contrived!'});
log.debug("After: " + this.model.get('name'))
if (this.model.hasChanged()) {
alert("This is never called.");
}
}
I would like to know why model.hasChanged()there is falsewhen the model is explicitly modified.
I'm not sure what other information is needed, but if there is more information that may be useful, please comment and I will clarify.
Thanks for reading.
source
share