Lets say I have name = ko.observable('John') that is bind to the input as value. I need to show (hidden before) <button>Save</button> if name get changed. So if I edit name from John to Jack then save button should appear and if edit back to John it should hide again. Have you any ideas of what kind of binding/extension can be applied here?
Great thanks!
Lets say I have name = ko.observable(‘John’) that is bind to the input as
Share
What you need is called dirty tracking.
There is a ko plugin called KoLite which contains a dirty flag implementation (you can read about how it works in this article):
The usage is very simple you just need to pass your obserables into the
ko.DirtyFlag(this will return computed observable) method:And in your view you can bind to the
isDirtyproperty on yourdirtyFlag:Demo fiddle.