Expand my Community achievements bar.

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?

Avatar

Level 4
 
1 Accepted Solution

Avatar

Correct answer by
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

Avatar

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

Avatar

Correct answer by
Level 6

Hi Karthick1356,

 

Have you tried in this way 

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

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