Reset changes method

This commit is contained in:
Anatoliy Chakkaev 2011-11-28 23:31:01 +07:00
parent 27af51a0d9
commit e72db08ad0
2 changed files with 10 additions and 5 deletions

View File

@ -394,13 +394,18 @@ AbstractClass.prototype.propertyChanged = function (attr) {
AbstractClass.prototype.reload = function (cb) {
var obj = this.constructor.cache[this.id];
if (obj) {
obj.reset();
}
this.constructor.find(this.id, cb);
};
AbstractClass.prototype.reset = function () {
var obj = this;
Object.keys(obj).forEach(function (k) {
if (obj.propertyChanged(k)) {
obj[k] = obj[k + '_was'];
}
});
}
this.constructor.find(this.id, cb);
};
// relations