0
私は次のjQueryテンプレートを持っており、特定のクラスを適用するための反復回数を追跡する必要があります。私は考えることができるすべての標準的なjavascriptのバリエーションを試してみました。jQueryテンプレートループカウンタ
$ iを反復処理してテンプレート内の$ iを参照するにはどうすればよいですか?テンプレート内の外部関数を呼び出す
<script type="text/html"id="sectionTemplate"> <span data-bind="css: { selected: $data == viewModel.selectedSection() }, click: function(i) { viewModel.selectSection($data) }">
${i++}
<input id="radio" class="ui-helper-hidden-accessible" type="radio" name="radio">
<label class="class${i}" for="radio${i}" aria-pressed="false" role="button" aria-disabled="false">
<span class="ui-button-text">${$data}</span></label>
</span>
jQueryのテンプレートdoT'または 'blueimp' https://github.com/blueimp/JavaScript-Templates –