jQueryTMPL插件
关于tmpl最令人恼火的事情是,您不能在诸如jQueryTMPL插件,jquery,jquery-templates,Jquery,Jquery Templates,关于tmpl最令人恼火的事情是,您不能在诸如 ${id}不会被替换 任何不必使用标签的想法,因为这不是一个好方法 甚至是如何选中复选框 我的模板看起来像这样 <table id="lvList" class="grid1"> <tr> <th>Name</th> <th>Number</th> <th>Type</th> &l
${id}不会被替换
任何不必使用
标签的想法,因为这不是一个好方法
甚至是如何选中复选框
我的模板看起来像这样
<table id="lvList" class="grid1">
<tr>
<th>Name</th>
<th>Number</th>
<th>Type</th>
<th>Account Manager</th>
</tr>
<!-- itemtemplate -->
<tr>
<td>{{html $item.href('details/?id=$id')}}</td>
<td>${id}</td>
<td>${type}</td>
<td>${accmgr}</td>
</tr>
<!-- itemtemplate -->
</table>
名称
数
类型
客户经理
{{html$item.href('details/?id=$id')}
${id}
${type}
${accmgr}
如果你想知道我是如何从表格中得到模板的,你可以看看这篇文章
使用这个模板,这就是我想到的
var items = $.tmpl(this.itemtemplate, data, {
href: function (url) {
for (i in this.data)
{ url = url.replace("$" + i, this.data[i]); }
return "<a href=\"" + url + "\">" + this.data["name"] + "</a>";
}
});
var items=$.tmpl(this.itemtemplate,data{
href:function(url){
对于(本.data中的i)
{url=url.replace(“$”+i,this.data[i]);}
返回“”;
}
});
为什么不使用脚本标记是个好主意?我想出了一个方法。看到我的问题,我仍然好奇为什么使用脚本标签来代替你的模板不是一个好主意。我确信这是可能的,在表格中间添加脚本标签似乎有点傻。感觉像一个开发者黑客!好啊忘了我一直在说的。。使用脚本非常简单:)
var items = $.tmpl(this.itemtemplate, data, {
href: function (url) {
for (i in this.data)
{ url = url.replace("$" + i, this.data[i]); }
return "<a href=\"" + url + "\">" + this.data["name"] + "</a>";
}
});