I have a list view that uses a datasource (see list view code below). Loads, works fine, no errors. When you click on an item in the list view, it redirects the URL to another page. After that redirected page shows up, a half-second later an error comes in the console that isn't very useful (see error below). After much tracing it seems that the error is being generated by the list view code which has since been unloaded because of the redirect.
Do I need to unregister/destroy datasources and widgets somehow before I redirect a page? Or some other problem? Apologies it's vague, very hard to debug.
Any help appreciated.
Cheers,
Brett
ListView Code:
$("#solutions-gallery-id").kendoListView({ dataSource: solutionsDataSource, selectable: true, template: kendo.template($("#solution-card-template-id").html()), change: function(e){ var selectedIndex = this.select().index(); var dataItem = this.dataSource.view()[selectedIndex]; window.location = window.location.protocol + "//" + window.location.host + "/solution/" + dataItem.solution_id; } });
Error:
kendo.all.js:186 Uncaught TypeError: Cannot read property 'replace' of undefined at Object.compile (kendo.all.js:186) at Object.d [as template] (jquery.min.js:2) at init.<anonymous> (4:489) at Object.i (kendo.all.js:7415) at Object.<anonymous> (jquery.min.js:2) at i (jquery.min.js:2) at Object.fireWith [as resolveWith] (jquery.min.js:2) at Object.e.(anonymous function) [as resolve] (http://localhost:3000/javascripts/jquery.min.js:2:29192) at success (kendo.all.js:6980) at Object.i.success (kendo.all.js:5911)compile @ kendo.all.js:186d @ jquery.min.js:2(anonymous) @ 4:489i @ kendo.all.js:7415(anonymous) @ jquery.min.js:2i @ jquery.min.js:2fireWith @ jquery.min.js:2e.(anonymous function) @ jquery.min.js:2success @ kendo.all.js:6980i.success @ kendo.all.js:5911i @ jquery.min.js:2fireWith @ jquery.min.js:2y @ jquery.min.js:4c @ jquery.min.js:4XMLHttpRequest.send (async)send @ jquery.min.js:4ajax @ jquery.min.js:4read @ kendo.all.js:5914(anonymous) @ kendo.all.js:6975d @ jquery.min.js:2_queueRequest @ kendo.all.js:7190_dequeueRequest @ kendo.all.js:7202success @ kendo.all.js:7072success @ kendo.all.js:6979i.success @ kendo.all.js:5911i @ jquery.min.js:2fireWith @ jquery.min.js:2y @ jquery.min.js:4c @ jquery.min.js:4XMLHttpRequest.send (async)send @ jquery.min.js:4ajax @ jquery.min.js:4read @ kendo.all.js:5914(anonymous) @ kendo.all.js:6975_queueRequest @ kendo.all.js:7190read @ kendo.all.js:6968(anonymous) @ 4:591i @ jquery.min.js:2fireWith @ jquery.min.js:2ready @ jquery.min.js:2K @ jquery.min.js:2