ListView of switches

2 posts, 0 answers
  1. Walid
    Walid avatar
    18 posts
    Member since:
    May 2013

    Posted 11 Jul 2013 Link to this post

    I have a basic listview, bound to a dataSource(JS array of objects), with an item template that contains a switch, 
    <script id="listItemTemplate" type="text/x-kendo-template">
                <a> #=name# </a>
                <input type="checkbox" #if(data.selected) { # checked #}# data-role="switch" data-bind="checked: selected" />

    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?

  2. Petyo
    Petyo avatar
    2436 posts

    Posted 12 Jul 2013 Link to this post

    Hi Walid,

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

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top