backbone.memento
backbone.memento copied to clipboard
Add keepState option to .restore()
Hi,
This PR adds the keepState
option for the .restore()
call.
When you call .restore()
, the default behaviour is pretty much the same as an "undo" feature. If I call .restore()
1 time more than I should, the model can be restored to even the point BEFORE it was synced with the server, which is not ideal in most (our) cases.
So this keepState
option behaves like a "clear dirty" feature, only the "dirty" changes get cleared. Call .restore({keepState:true})
as many times as you want, and the model will always be restored to the state of the last .store()
.