I am using Knockout Js for my view page. I have a requirement where if any editable field changes, I have to enable Save button else not. This is working nicely.
My issue is I have checkboxes too for each row of item. These are observable items in my viewModel. What happens now is when I check or uncheck any checkbox, Knockout considers that as Dirty item and enables the Save button which I don’t want.
How can I tackle this?
I am not sure of the exact code that you are using for a dirty flag, but if it involves using
ko.toJSin a dependentObservable like this, then there is a trick that you can use to have it skip some observables.If you create an observable that is a property of a function, then
ko.toJSwill not find it.Here are two examples (
someFlagandanotherFlag):Sample here: http://jsfiddle.net/rniemeyer/vGU88/