When I pass {\"silent\":true}
while setting an attribute in a Backbone model, why doesn\'t that just suppress the change:attribute
event? What is the a
In backbone 0.9.2 the set
function runs validation before any changes are updated.
// Run validation.
if (!this._validate(attrs, options)) return false;
In case of {silent: true}
option is passed, the validation code will not be executed.
if (options.silent || !this.validate) return true;
That means, model.set({value: 100}, {silent: true});
is able to set "invalid" value into model, so attributes are updated, but change event's are not firing.
It is useful, then you want to update some field and prevent whole mode validation, so if model is not yet completed, the change still propagated to attributes. But you usually you also want the view to show the change, so you have to manually call model.change()
or model.trigger('change:value', model, value)
.