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

Template loses click binding when dataSource is updated.

3 Answers 76 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 11 Oct 2013, 08:06 PM
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?

3 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 15 Oct 2013, 06:52 AM
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!
0
Hugo
Top achievements
Rank 1
answered on 10 Jan 2014, 05:22 PM
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?
0
Kiril Nikolov
Telerik team
answered on 14 Jan 2014, 08:42 AM
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!
Tags
Templates
Asked by
Jeff
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Hugo
Top achievements
Rank 1
Share this question
or