【发布时间】:2013-02-08 11:28:45
【问题描述】:
我有一个模板(一个 html 文件),它使用 JSRender 获取带有 JSON 数据的渲染。
我的示例模板如下
<ul id="membersList">
{{for UserConnection}}
<li>
<div>
<a title="{{:Fullname}}">
<br />
<img src="sample.png"/><br />
{{:Fullname}}</a>
</div>
</li>
{{/for}}
我的 Json 数据是
[
{
"ApplicationName": "appone",
"Title": "Title one",
" UserConnection ": [
{
"Id": 210,
" email ": " abc1@xyz.com ",
},
{
"Id": 0,
" email ": " ",
},
{
"Id": 211,
" email ": " abc2@xyz.com ",
}
]
}
];
现在我的要求是我应该隐藏 div 如果特别是第二项 JSON 的 id 值为 0。
是否可以在 JSRender 中检查我们在 c# 中所做的一些事情,例如
for (i = 0 ; i < 10 ; i++)
{
if (userConnection[i] = 0)
// show the div
else
// dont show
}
即如果即使在 JSRender 中我也可以访问 UserConnection[i],那么我可以显示或隐藏 div。 有可能吗?
【问题讨论】: