I am trying to learn more about jQuery templates but cant seem to execute any JS calls inside the template.
<script id="log-item" type="text/x-jquery-tmpl">
{{if title.length }}
<h3 style="padding-bottom:5px;">${ title }</h3>
{{/if}}
objectToString(${ detail });
</script>
Note that my objectToString() function is never called, just rendered out as a string. I tried wrapping it in {{ }} on a whim but no luck. Anyone out there who can help?
Anthony, you can. The method your calling needs to be inside a template tag like so:
<script id="log-item" type="text/x-jquery-tmpl">
{{if title.length }}
<h3 style="padding-bottom:5px;">${ title }</h3>
{{/if}}
<p>
Detail: ${ objectToString( detail ) }
</p>
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With