kendo-labs / knockout-kendo

A project to create a robust set of Knockout.js bindings for the Kendo UI widgets.
http://kendo-labs.github.com/knockout-kendo/
273 stars 144 forks source link

DropDownList value not updating #19

Closed sgreer closed 12 years ago

sgreer commented 12 years ago

Ryan,

I have a feeling this is more a Knockout/KendoUI item than the custom bindings that you have created. However, from viewing your responses on the Knockout forum and Stackoverflow, I've decided to post here in hopes I can get access to some of your Knockout expertise.

The following fiddle shows the issue that I am facing: http://jsfiddle.net/sgreer/3gDxd/

I am building a form for editing a person record and part of that record is the ability to edit multiple address types. I have it working with the exception of the Kendo DropDownList. It works properly for setting the state code on each address, however when I change the address that is currently being edited, the DropDownList for the state is not updated to reflect the value stored in the address object.

To see what I mean, run the fiddle and set the state for the Business address to California. Then change the address type to PO Box. First note that the DropDownList value remains California when the underlying state value is undefined. Now set the state to Nevada and navigate back to the Business address - the state remain Nevada.

Thanks for any guidance that you can provide.

Sean

rniemeyer commented 12 years ago

Hi Sean- I would probably go for something like this: http://jsfiddle.net/rniemeyer/uzEzZ/. I used the kendoDropDownList binding on the state field and wrapped the form in a with: SelectedAddress. This helps simplify the bindings and causes the inputs to re-render when changing between address types.

Hope this helps.

sgreer commented 12 years ago

Ryan,

This is exactly what I needed. Being somewhat new to Knockout, that's the first use of the with binding.

Thank you very much. Next time I'll post on stackoverflow so I can give you some points. ;)

Sean