This is a migrated thread and some comments may be shown as answers.

Binding templated ul to selected dropdown item

5 Answers 63 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 26 Feb 2013, 05:02 PM
I'm trying to bind a unordered list of checkboxes to a dropdown. It's very similar to cascading dropdowns. The trouble is that when the ul is bound with the template the checkboxes aren't bound to the array in the view model right away. When I change the dropdown selected item the ul updates but the checkes don't update until I click on them. It's difficult to explain so I've created a jsbin here.

In the example, I check App1, then select Administrator from the dropdown, and then select Instructor from the dropdown. App1 is no longer checked but if I click App2 to check it, App1 becomes checked. So the binding must have occurred.

Any help would be appricated.

5 Answers, 1 is accepted

Sort by
0
Jon
Top achievements
Rank 1
answered on 26 Feb 2013, 05:15 PM
Updated jsbin to Q3 SP. 

http://jsbin.com/edanig/4/edit 
0
Daniel
Telerik team
answered on 28 Feb 2013, 04:19 PM
Hi,

The problem occurs because value binding is used for the checkbox. Setting the value through the template syntax should resolve the problem. I updated the jsBin.

Kind regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jon
Top achievements
Rank 1
answered on 28 Feb 2013, 04:31 PM
Thanks, that works. I also found this page on Stack Overflow. It's very similar and may provide a better solution for what I'm attempting.
0
Jon
Top achievements
Rank 1
answered on 04 Mar 2013, 08:05 PM
Daniel,

If I provide values for the membership array in the jsbin you provided, how do I get the checkboxes to bind to it. That is, if memberships is [2,3], the checkbox for App2, and App3 isn't initially checked.
0
Accepted
Daniel
Telerik team
answered on 06 Mar 2013, 03:10 PM
Hello Jon,

The array values should be strings in order for the values to be matched and the checkboxes checked initially. I updated the sample.

Kind regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MVVM
Asked by
Jon
Top achievements
Rank 1
Answers by
Jon
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or