'Want to have a condition checked up in a method in jsview
I am new to JsViews. In one of the template, I have to set multiple conditions for rendering :
<tr>
{{if condition1 || condition2 || condition3}}
<td class="formLabel"
style="padding-left:2px;vertical-align:middle;text-align:left;font-size:8pt;font-family:sans-serif;"
width=""><span id="{{attr:firstChild().id()}}_labelSpan" style="color:#000000;">{{attr:childAtIndex_(1).paramAt_('label')}}</span>
</td>
<td style="vertical-align:middle;" width="200px">{{:renderChildren()}}</td>
{{else}}
<td style="vertical-align:middle;" width="200px">{{:renderChildren()}}</td>
<td class="formLabel"
style="padding-left:2px;vertical-align:middle;text-align:left;font-size:8pt;font-family:sans-serif;"
width=""><span id="{{attr:firstChild().id()}}_labelSpan" style="color:#000000;">{{attr:childAtIndex_(1).paramAt_('label')}}</span>
</td>
{{/if}}
</tr>`
Can I put the multiple condition in the a method at the template level
Solution 1:[1]
Yes, you can do that. See the documentation on "Paths and expressions".
As examples, see the sample at the bottom of the {{if}} tag topic, which does:
{{if members && members.length}}
...
{{else standby && standby.length}}
Standby only:
...
{{else}}
No members!
{{/if}}
This sample also shows examples of using expressions in JsRender tags, such as:
{{if address && address.street}}
and
{{:~lateMessages.noAddress || ~messages.noAddress}}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | BorisMoore |
