I'm using models in yui3, and although there are functions like reset() and undo(), they don't quite accomplish what I'm looking for.
I set values at different times, but may want to just undo everything to the point of the last save... is there a way to do so at this time?
In 3.5.0pr2 (pr2 is currently on the Yahoo! CDN; 3.5.0 GA will be released in mid-March), you can try something like this:
var MyModelClass = Y.Base.create('mine', Y.Model, [], {
initializer: function () {
this._saveState();
this.after('save', this._saveState);
},
_saveState: function (e) {
this._lastState = this.toJSON();
},
restoreLastSaved: function () {
this.setAttrs(this._lastState);
}
});