Hi,
I have 2 arrays question is multiitem and answer which is multi item again
I wanted to display answer under the question. I am trying to access question by index so that I can fetch corresponding answer
How can I do that with sightly?
<ul data-sly-list="${properties.question}">
<li>${ [ item ]}</li>
</ul>
<ul data-sly-list="${properties.answer}">
<li>${ [ item ]}</li>
</ul>
The above code displays all questions and displays all answers at the end of questions.
Thanks for your help!
Solved! Go to Solution.
In your example, i'm pretty sure you can do something like this:
<ul data-sly-list="${properties.question}"> <li> Question: {item} Answer: ${properties.answer[itemList.index]} </li> </ul>
In your example, i'm pretty sure you can do something like this:
<ul data-sly-list="${properties.question}"> <li> Question: {item} Answer: ${properties.answer[itemList.index]} </li> </ul>
See this Sightly article - we handle a Java collection in Sightly:
Creating a Sightly and Sling Model DOM parser component
div data-sly-test=
"${properties.img=='true'}"
data-sly-use.img=
"com.mycompany.myproject.components.Parser"
>
<b>Here are the Images</b>
<ul data-sly-list=
"${img.images}"
>
<li><img src=
"${item}"
></li>
</ul>
</div>
Views
Replies
Total Likes
leeasling wrote...
In your example, i'm pretty sure you can do something like this:
<ul data-sly-list="${properties.question}">
<li>
Question: {item}
Answer: ${properties.answer[itemList.index]}
</li>
</ul>
It worked.Thanks for your answer.
Views
Likes
Replies