Template loses click binding when dataSource is updated.

4 posts, 0 answers
  1. Jeff
    Jeff avatar
    1 posts
    Member since:
    Oct 2013

    Posted 11 Oct 2013 Link to this post

    Hello,

    I'm trying to use a template for a kendoListView. In the template, I have an element that uses data-bind for a click event handler.

    Everything works fine until I update the dataSource of the listView. Once the dataSource is updated, none of the click handlers work anymore.

    JSFiddle:
    http://jsfiddle.net/jseets/Qh2ma/11/

    Any ideas?
  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 15 Oct 2013 Link to this post

    Hi Jeff,

    The problem comes from the fact that you are manually initializing the Kendo UI ListView and after the dataSource is updated with the new item, the ListView is not reinitialized automatically, so it looses its click handlers.

    I have modified your example to show how to correctly bind a ListView using MVVM:

    http://jsbin.com/iRUTEHO/1/edit
     

    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Hugo
    Hugo avatar
    28 posts
    Member since:
    May 2011

    Posted 10 Jan 2014 Link to this post

    Hello Kiril,

    I have a similar example but I'm using kendo.data.ObservableObject.extend. I have a listview in my HTML with "data-source" where each item is a kendo-template with '... data-bind="click: submit" ...'

    When this page is shown for the first time, the click works, but the problem is that when the datasource of the listview is changed (using fetch()), that bind click is lost. Is there a way to render the listview again?
  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 14 Jan 2014 Link to this post

    Hello Hugo,

    Could you please extract a runnable sample, that we can take a look at?

    From the provided information it is not possible to determine what is the reason for your issues.

    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready