我正在使用插件jquery-tmpl。有没有办法在模板运行后指定回调?我想做类似的事情
<script id='itemTemplate' type='text/html'>
<li class="item" id=${timestampMs}>
<span class="content">${content}</span>
</li>
${processItem($('#' + timestampMs))}
</script>
对刚刚生成的元素processItem
做了什么。但是,正如它所写的那样,该元素在被调用<li>
时并不存在。processItem
这是我运行模板的方式:
// 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');
}
});
谢谢!