Updated isDirty function to check individual attributes#28
Updated isDirty function to check individual attributes#28thecountofzero wants to merge 5 commits intojupiterjs:masterfrom thecountofzero:isAttrDirty
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.