Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model.clear() does not work when model is invalid #141

Open
pgilad opened this issue Jul 30, 2015 · 2 comments
Open

model.clear() does not work when model is invalid #141

pgilad opened this issue Jul 30, 2015 · 2 comments

Comments

@pgilad
Copy link

pgilad commented Jul 30, 2015

model.clear() does not work when model does not pass validation:
https://github.com/afeld/backbone-nested/blob/master/backbone-nested.js#L118-L120

  1. What is the logic behind even checking if model is valid when clearing it?
  2. this.validate is supposed to return undefined. What is the reason behind this check?
  3. Code does not make sense.
@fabien
Copy link

fabien commented Mar 3, 2016

Just bumped into to this issue myself - doesn't make any sense ...

@jacobbuck
Copy link

jacobbuck commented May 6, 2016

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});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants