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

ListView of switches

1 Answer 142 Views
Switch (Mobile)
This is a migrated thread and some comments may be shown as answers.
Walid
Top achievements
Rank 1
Walid asked on 11 Jul 2013, 01:35 PM
Hello,
I have a basic listview, bound to a dataSource(JS array of objects), with an item template that contains a switch, 
Ex:
<script id="listItemTemplate" type="text/x-kendo-template">
       <div>
            <a> #=name# </a>
            <input type="checkbox" #if(data.selected) { # checked #}# data-role="switch" data-bind="checked: selected" />
       </div>
</script>

The list is rendered corectly, however the switch data binding does not seem to be working. 
Had to specify the [#if(data.selected) { # checked #}#], otherwise it woudn't have set the checked state corectly.
I expect 2 way binding. Thiking this should work.
Am i doing something wrong?

Regards

1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 12 Jul 2013, 07:12 AM
Hi Walid,

In order for the two-way binding to work, you will have to employ the MVVM pattern. Please check this example

Regards,
Petyo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Switch (Mobile)
Asked by
Walid
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or