1

是否可以在 jtemplate 中创建局部变量或 for 循环(而不是 foreach)?我想为 HTML 元素提供唯一的 id,并且需要一个计数器或其他东西。谢谢!

4

1 回答 1

4

采用$index

$index - index of the element in the table
$iteration - ID of the iteration (the next number begins from 0)
$first - is this the first iteration?
$last - is this the last iteration?
$total - the total number of iterations

前任

{#foreach $T.Rows as row}
  $T.row$index
{#/for}

阅读http://www.codeproject.com/Articles/45759/jQuery-jTemplates-Grid

于 2012-04-23T17:33:47.290 回答