【发布时间】:2011-12-24 01:21:32
【问题描述】:
我正在尝试 jsRender。
我想做什么:
JS 模板:
<script id="theaterTemplate" type="text/x-jquery-tmpl">
{{*
if ("{{=theaterId}}" == getCurrentTheaterId()) {
}}
<a class="active" href="#">
{{*
} else {
}}
<a href="#">
{{* } }}
{{=theaterName}}
</a>
</script>
在其他 JS 中:
function getCurrentTheaterId() {
return "523";
}
基本上,在模板中,如果迭代中的当前剧院 id 与 js 函数返回的内容匹配,则将类设置为活动。 "{{=theaterId}}" 在 if 条件中中断。我猜你不允许在 if 条件下访问当前的 json 属性。
关于如何做到这一点的任何想法?
希望这是有道理的。谢谢!
【问题讨论】:
标签: javascript plugins jsrender