Tilelayout with script templates created in JS does not work in Firefox

1 Answer 19 Views
Templates TileLayout
Top achievements
Rank 1
Lieven asked on 18 Feb 2022, 11:15 AM | edited on 18 Feb 2022, 11:16 AM


In the TileLayout DEMO (https://demos.telerik.com/kendo-ui/tilelayout/index, script tags are used in the html code.
We want to create the script tag with the javascript code.

For example in the demo page is written:
 id="views-chart-template" type="text/x-kendo-template"> <div id="views-chart" style="height:100%; width:100%"></div> </script>

When replacing this html code by the JS code :
     var s = document.createElement('script');
      s.id = "visitors-chart-template";
      s.setAttribute('type', "text/x-kendo-template");
      var d = document.createElement('div');
      d.id = "visitors-chart";
      d.style = "height:100%; width:100%";

Then this works in Chrome and Microsoft Edge, but not in Firefox.

The HTML page is added in the appendix. When opening this in Firefox, you will see that the "Visitors" dashboard card content is not filled in. When opening this HTML page with Chrome, then the "Visitors" dashboard is okay.

Thanks in advance.

1 Answer, 1 is accepted

Sort by
Georgi Denchev
Telerik team
answered on 23 Feb 2022, 09:33 AM

Hi, Lieven,

Thank you for the provided details and code snippets.

This seems to be a problem related to FireFox/JQuery rather than the widget itself. The html() method returns an empty string when the element is created in the provided manner.

You'll have to find a different way to get the contents of the <script></script> tags as a string, here's on example:

bodyTemplate: kendo.template($("#visitors-chart-template").contents()[0].outerHTML)

Runnable Dojo:


Best Regards,
Georgi Denchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Templates TileLayout
Asked by
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
Share this question