I'm using the plugin jquery-tmpl. Is there a way to specify a callback after a template is run? I want to do something like
<script id='itemTemplate' type='text/html'>
<li class="item" id=${timestampMs}>
<span class="content">${content}</span>
</li>
${processItem($('#' + timestampMs))}
</script>
Where processItem
does something to the <li>
element that just got generated. As it's written, though, the element doesn't exist at the time processItem
is called.
Here's how I run the template:
// Make the AJAX call to the service
$.ajax({
dataType: "json",
url: "/getItems",
success: function(data) {
// fill out template from json
$('#itemTemplate').tmpl(data).appendTo('#container');
}
});
Thanks!