JsRender If Conditions Comparing Variables Between Child Objects
I am trying to achieve this in JsRender. As You can see from the code below, SubMenuItems and SubMenuPages are child objects in a array of objects.However, I would like to compare
Solution 1:
So is SubMenuItems
an array of items of which each has a PageMenuId
- or is it a single object as you seem to say? (And similarly, is SubMenuPages
an array of items each of which has an Id
?)
It is difficult to answer your question without more clarity on your data hierarchy, but basically the documentation here View Hierarchy - and in particular here Accessing parent data should tell you what you need to know.
If my guess about your data structure is correct, then here is one way you can write your template:
...
{{for SubMenuItems itemVar="~SubMenuItem" ~Pages=SubMenuPages}}
...
{{for ~Pages itemVar="~SubMenuPage"}}
...
{{if ~SubMenuItem.PageMenuId == ~SubMenuPage.Id }}
...
{{/if}}
...
{{/for}}
...
{{/for}}
...
You could also look at these stack overflow questions which are similar to yours:
Post a Comment for "JsRender If Conditions Comparing Variables Between Child Objects"