0

I have created the following js fiddle http://jsfiddle.net/pltaylor3/DsJKp/ to attempt to bind the dates that MVC4 creates to a user editable date that can be sent back to the server as well. My date is displaying properly but when I edit the date it does not appear to update the knockout model. What am I missing from my custom binding to update the Knockout model. I know there is some logic missing for updating the day and year but the month should be updatable.

PlTaylor
  • 7,345
  • 11
  • 52
  • 94
  • You should use the `init` function to setup an event handler to handle changes that a user makes to the field by updating the observable. In the `update` function you should update the field based on the value of the observable. The `update` function will be called whenever the observable's value changes (such as when you change it programmatically). Basically, you current binding has no event handler to capture the changes that a user makes to the field. – RP Niemeyer Aug 02 '12 at 18:40
  • Something along these lines? http://jsfiddle.net/pltaylor3/DsJKp/3/ – PlTaylor Aug 02 '12 at 19:09
  • I didn't look at the specific logic, but you have the exact right idea. The event handler updates the model value and the update function keeps the field in sync with the model. – RP Niemeyer Aug 02 '12 at 20:08

0 Answers0