Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

iterating over array of objects using data-sly-list using JS use api causing issues

Avatar

Avatar
Level 1
pratikshag92644
Level 1

Likes

0 likes

Total Posts

5 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
pratikshag92644
Level 1

Likes

0 likes

Total Posts

5 posts

Correct Reply

0 solutions
View profile
pratikshag92644
Level 1

03-08-2018

Hi,

I have a multifield component in rtouch UI and its values are getting saved in JCR:content as a node property in the form of string[]. Now I am retrieving the array inside javascript use(function(){}) and iterating over the object using data-sly-list. Below is my code:

var linkObj =[{"title":"SAS App","path":"/content/sassi-blueprint/en/products/sas-app"},

             {"title":"Charter Information","path":"/content/sassi-blueprint/en/products/charter-information"},

             {"title":"Welcome to Global Internet Support","path":"/content/sassi-blueprint/en/digital-channels/welcome-to-global-internet-support"},

             {"title":"Manual reservation","path":"/content/sassi-blueprint/en/digital-channels/manual-reservation"}

            ];

    return{

        linkObj: linkObj

    }

<ul  data-sly-list="${info.linkObj}" >

     <li class="col-lg-4 col-md-4 col-sm-4 col-xs-12">

          <span>${item}</span>

     </li>

</ul>

The output for this is

title, path

title, path

title, path

title, path

Instead of the values it prints the properties. Is there something wrong with the linkObj? Can it be done through JS or do we need to achieve this through java?

Replies

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,346 likes

Total Posts

3,223 posts

Correct Reply

915 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,346 likes

Total Posts

3,223 posts

Correct Reply

915 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

03-08-2018

Yes, your code is not correct. you need to do like ${item.property}

e.g.

<ul data-sly-list="${info.linkObj}" >

     <li class="col-lg-4 col-md-4 col-sm-4 col-xs-12">

          <span>${item.path}</span> -----  <span>${item.title}</span>

     </li>

</ul>

Thanks

Arun

Avatar

Avatar
Level 1
pratikshag92644
Level 1

Likes

0 likes

Total Posts

5 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
pratikshag92644
Level 1

Likes

0 likes

Total Posts

5 posts

Correct Reply

0 solutions
View profile
pratikshag92644
Level 1

08-08-2018

Yes i did that. There was some issue with the object itself but it's resolved now. Thanks.