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

unsetting attributes during restore/restart conflicts with backbone validation #14

Open
adamlangsner opened this issue Aug 1, 2012 · 1 comment

Comments

@adamlangsner
Copy link

In my application when a user changes their password we ask them for their current password and the new password. When the user first enters this modal window I call store() on the User model to save a copy of it.

I then set the 'oldPassword' and 'newPassword' attributes on the User model in a save() call. After the backend has been updated I call restart() to get the original state of the User model because I want to remove the 'oldPassword' and 'newPassword' attributes, don't want to keep that info around in memory.

The problem arises because I'm using the Backbone Validation plugin https://github.com/thedersen/backbone.validation. When memento calls unset() on the model for these two attributes it calls _validate() on the model and it fails because memento is trying to set the attributes to null, and I've specified them as required via the validation plugin. I thought about 2 potential fixes:

  1. pass the restoreConfig object in restore() and restart() down the line to the unset() call in TypeHandler.removeAttr(), this way you could do this: model.restart({silent: true}); // skip validation
  2. pass {silent: true} into the unset() call in TypeHandler.removeAttr(), this would skip validation every time attributes need to be unset, not very flexible though.
@pppdns
Copy link

pppdns commented Jan 18, 2016

I know it's an old thread but are there any changes here? Is thedersen/backbone.validation' compatible with Memento already? thanks

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

2 participants