You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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
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.
The text was updated successfully, but these errors were encountered:
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:
model.restart({silent: true}); // skip validation
{silent: true}
into the unset() call in TypeHandler.removeAttr(), this would skip validation every time attributes need to be unset, not very flexible though.The text was updated successfully, but these errors were encountered: