Search code examples
javascriptasp.net-mvctelerik-reporting

Existing javascript not executing MVC 5 Telerik


I have a working MVC 5 application with custom Javascript functions which have been working since I created them.

I now included Telerik as described in the guide here: http://www.telerik.com/help/reporting/mvc-report-viewer-extension-embedding.html .

Since I included the Telerik reporting module my Javascript does not work anymore. It is loaded but does not execute. I added an alert in the beginning of the function and the alert is not showing either. As illustration:

$('.cbTreeViewItem').click(function () {
    alert("test");
}

Is included but not executed. Before adding Telerik it worked as expected.


Solution

  • It seems adding Telerik slowed down the loading process causing the custom Javascript files not to be properly loaded.

    Wrapping my custom Javascript files as below resolved the issue for me.

    $( document ).ready(function() {
        // custom functions for the given page
    })