'is it possible to have a for loop in JSRender with incremental variable i?
i have template (an html file) with is getting renders with JSON data using JSRender.
My Sample Template is as follows
<ul id="membersList">
{{for UserConnection}}
<li>
<div>
<a title="{{:Fullname}}">
<br />
<img src="sample.png"/><br />
{{:Fullname}}</a>
</div>
</li>
{{/for}}
My Json data is
[
{
"ApplicationName": "appone",
"Title": "Title one",
" UserConnection ": [
{
"Id": 210,
" email ": " [email protected] ",
},
{
"Id": 0,
" email ": " ",
},
{
"Id": 211,
" email ": " [email protected] ",
}
]
}
];
Now my requirement is the i should hide of div if in particular the 2nd item of the JSON has the its id value as 0.
Is it possibel in JSRender to check some thing which we do in c# like
for (i = 0 ; i < 10 ; i++)
{
if (userConnection[i] = 0)
// show the div
else
// dont show
}
i.e. if i can access UserConnection[i] even in JSRender, then i can show or hide the div. Is it possible?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
