backbone-nested
backbone-nested copied to clipboard
model.clear() does not work when model is invalid
model.clear() does not work when model does not pass validation:
https://github.com/afeld/backbone-nested/blob/master/backbone-nested.js#L118-L120
- What is the logic behind even checking if model is valid when clearing it?
this.validateis supposed to return undefined. What is the reason behind this check?- Code does not make sense.
Just bumped into to this issue myself - doesn't make any sense ...
We just noticed this too. It does seem a bit odd, but after some further investigation it's actually replicating existing Backbone behaviour:
Backbone.Model.prototype.clear() will run Backbone.Model.prototype.set(), which will validate the model before setting.
You can get past this by passing the validate option as false:
someNestedModel.clear({validate: false});