Hello-
I listed some thoughts on some options for this accept/cancel scenario in this
post.
A few options:
1- create a clone of your object for editing and broker the values back and forth between the real objects on edit/save. On cancel just throw it away.
2- create edit properties on your objects and copy the values to the real ones on commit. As you noted this can add a lot of bloat to your view model.
3- In the post, I describe creating an extended observable that supports caching the edited value and committing/resetting the value. Now, you can just define your properties as protectedObservables instead of observables. Sample here:
http://jsfiddle.net/rniemeyer/X9rRa/4- Similar to #1 and based on #3, you could create a modified observable that supports cloning an object for editing and writing it back on commit. Recently we were playing with that idea in this
post. Sample here:
http://jsfiddle.net/rniemeyer/np4Ve/5- I have been playing with a new method that is slightly simpler than above. We can create a custom binding that is a wrapper to the value binding. Instead of setting up events against the real observable, instead we substitute a writeable dependentObservable that intercepts the edits and puts them into a "tempValue" property on the observable itself. On an accept, we loop through the properties and look for any "tempValue" sub-properties. When we find a tempValue then we commit it to the real observable. Hope that makes sense. It does slightly simplify the scenario. In the UI we just use the "tempValue" binding instead of "value". Sample here:
http://jsfiddle.net/rniemeyer/mVPfw/ Could probably use a little more error checking in the binding.
Hope these ideas help. I think that they will ultimately work out better than trying to bind/unbind the UI. I would be happy you get any of these ideas or other ideas that you have working for your scenario.