-
Notifications
You must be signed in to change notification settings - Fork 374
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
Updated isDirty function to check individual attributes #28
base: master
Are you sure you want to change the base?
Conversation
This should really use $.Object.same now ... |
Trying to consume this. How would I use $.Object.same to determine if a specific attribute of a model has been changed? isDirty: function(option) { Or are you saying that it shouldn't even be in backup.js? |
What shouldn't be in backup? Do you need to know the specific attribute? |
The functionality that I was trying to provide was to give a way to determine if a specific attribute of a model has been changed (is dirty). |
ah ... hmmm. $.Object.same might need to be able to provide the attributes that are different. |
Are you completely against having isDirty in backup.js defined as: isDirty: function(option) {
// check if it serializes the same
if(!this._backupStore){
return false;
} else {
if(typeof option === "string") {
var current = this.attrs();
return current[option] !== this._backupStore[option] ? true : false;
}
else return !same(this.serialize(), this._backupStore, !!option);
}
}, It works nicely and is simple |
Re-worked previous attempt to allow for checking if an model attribute is dirty.
Updated the isDirty function to all for passing in a string (name of attribute).
Checking typeof arg. If "string" then we check the attribute for dirtiness. Otherwise proceed as usual.