Closed shanmudev closed 7 years ago
This seems to be an issue with Chrome. In other browsers it renders without error. In Chrome it errors if you put while (i<900)
, but if you put while (i<400)
(or less) it works without error.
Your way of creating the template has 900 * 4 = 3600 {{: ...}}
tags in a single template. Chrome throws an error while compiling that template - because of some kind of limit they have on JavaScript expressions of the form ret="..." +((v=...)!=null?v:"") + "..." +((v=...)!=null?v:"") + "..." +((v=...)!=null?v:"")...
(where you have >7200 such terms added together to produce a single string variable).
I'd suggest you instead use a template along the lines of
<tr style = 'height: {{:height}}px' idx = '{{:rowidx}}'>
{{for cols}}
<td class='{{:_className}}' rowspan=' {{:_rspan}}' colspan=' {{:_cspan}}'>{{:_value}}</td>
{{/for}}
</tr>
Then you can render the template with data which has a cols array of 900 items for the columns:
var data = {
height: 220,
rowidx: "a",
...
cols: [
{_value: "AVal", _className: "AClass", ...},
{_value: "BVal", _className: "BClass", ...}
...
]
};
Closing - since this is not a JsRender bug (really a Chrome bug), and there is a workaround proposed...
I am facing the error while creating 900 columns in the table by using jsrender. I have used the below code.
While running the sample getting the error.
The error occurring in > jsrender-1.0.0-beta.js < . Which is working fine in exact jsrender-1.0.0-beta.js version. Is this an issue?.
JSFiddle link: https://jsfiddle.net/z8fqs1yb/2/