So I have this JQuery template that calls a function:
<script id="Fred" type="text/x-jQuery-tmpl">
<td>${functionX()}${Field2}</td>
</script>
Works great. but now I want to pass a parameter into it, but the following won't work.
<script id="Fred" type="text/x-jQuery-tmpl">
<td>${functionX(${Field1})}${Field2}</td>
</script&g开发者_Go百科t;
Any suggestions?
You can access Field1 directly without using ${, like:
<td>${functionX(Field1)}${Field2}</td>
figured it out:
<td>${functionX($data.Field1)}${Field2}</td>
This is another example of how the problem could be solved:
<script id="testTemplate" type="text/x-jquery-tmpl">
{{if title.length}}
<h3>${title}</h3>
<p>Start: ${ render($data) } :End</p>
{{/if}}
</script>
You can see that this method works in this link.
精彩评论