IF
jQueryテンプレート内でステートメントをどのように使用しますか?
これが私のテンプレートです:
<script type="text/html" id="attachmentListTemplate">
{{if $item.current_cmt_id == id }}
<li>
<a href="${link}" class="fancyIFrame clearfix">${title}</a>
</li>
{{/if}}
</script>
ここで、idは基本的${id}
に、データバインディングによって(KnockoutJSを介して)渡されます。IFステートメントがないと、次のように正常に出力されます。${$item.current_cmt_id}
データバインディングは次のとおりです(KnockoutJSを利用)。
<ul data-bind='template: { name: "attachmentListTemplate", foreach: attachmentsModel.convAttachments, templateOptions: {current_cmt_id: <%=comment.id%>} }'> </ul>
if sttatementが機能しない理由について何か提案はありますか?2つの条件を正しく比較していますか?