Search code examples
knockout-2.0kolite

Sample example or tutorial using knockout KoLite for change tracking


Is there any simple example on how to use knockout kolite to track the changes. I saw this link posted by john papa [Kolite][1]. I didnt understood how he is binding changes to the html element for tracking changes. Anyone have any simple example of how to use it then its highly appreciated. I am newbee when it comes to knockout. Please help. Many thanks

I found one example. Here is link to fiddle KoLite example

In fiddle you can see that save button is hiding and unhiding properly if there are any changes made to input field. I added code to enable the Cancel button but its not working.

<div data-bind="enable: dirtyFlag().isDirty">
       <button>Cancel</button>
</div>

Please can you tell me why?


Solution

  • There you go:

    http://jsfiddle.net/6dz7g/12/

    <input type="text" data-bind="value: name, valueUpdate: 'keyup'"/>  
    
    <div data-bind="if: dirtyFlag().isDirty">
        <button>Save</button>
    </div>  
    
    <div>
        <button data-bind="enable: dirtyFlag().isDirty">Cancel</button>
    </div>
    

    I've simply used ifnot binding for the save button.