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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

how to dynamically change data-attribute? for example data-off-right="${model.value1}", here i want "right" should be dynamic. how can i achieve this?

karthick1356
Level 2
Level 2
 
1 Accepted Solution
kchaurasiya
Correct answer by
Level 6
Level 6

Hi Karthick1356,

 

Have you tried in this way 

<sly data-sly-test.right=${right.value} />

 data-off-${right}="${model.value1}"

View solution in original post

2 Replies
Ritesh_Mittal
Community Advisor
Community Advisor

Hi @karthick1356 ,

 

You can use 'data-sly-attribute' HTL block to achieve this. its supports map (key-value), and the key automatically becomes atribute in html mark-up.

Reference -

https://experienceleague.adobe.com/docs/experience-manager-htl/using/htl/block-statements.html?lang=...

https://www.youtube.com/watch?v=LhvSNVagoZk

kchaurasiya
Correct answer by
Level 6
Level 6

Hi Karthick1356,

 

Have you tried in this way 

<sly data-sly-test.right=${right.value} />

 data-off-${right}="${model.value1}"

View solution in original post