不,这不是重复的this question ......虽然有点相关,所以我将使用来自该Q的代码进行比较。在jquery tmpl中获取索引
我试图从嵌套模板中使用{{tmpl}} tag获取索引。使用tmlp标记与上面链接的问题中的{{each}}标记非常相似,但$ index属性不存在。
<script id="answerTable" type="text/x-jquery-tmpl">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
{{tmpl(answersObj) '#answers' }}
</table>
</script>
<script id="answers" type="text/x-jquery-tmpl">
<tr>
<th><input type="radio" name="group1" value="---!INDEX HERE!---" /></th>
<td>${AnswerText}</td>
</tr>
</script>
我不想用一个混乱的方式做这个 - 我宁愿如果可以修改的lib拉闸。任何人有任何想法可以修改当前的lib来支持这个功能 - git hub source。这段代码稍微超过我的脑袋,时间紧迫,并且理解这个lib不在我目前的项目范围之内;)
小怪想要临时代表 – 2010-12-14 02:11:23
哈。那么你不能补充赏金,除非你有至少75 ...反正我自己回答Q.所以不需要投票... – user406905 2010-12-14 02:14:38
并等待两天 – 2010-12-14 02:16:51