4
我有模板(一个HTML文件)与使用JSRender的JSON数据呈现。是否有可能在JSRender中使用增量变量i有for循环?
我的样品模板是如下
<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 ": " [email protected] ",
},
{
"Id": 0,
" email ": " ",
},
{
"Id": 211,
" email ": " [email protected] ",
}
]
}
];
现在,我的要求是我应该隐藏DIV的,如果在 特别是第2项的JSON具有价值的其ID为0
是它JSRender possibel查一些东西,我们在C#中做像
for (i = 0 ; i < 10 ; i++)
{
if (userConnection[i] = 0)
// show the div
else
// dont show
}
即如果我能即使在JSRender访问UserConnection [I],那么我可以显示或隐藏在div。 这可能吗?
{{:#index + 1}}是对我的帮助。 :) – 2013-02-11 04:57:43