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? | Community
Skip to main content
Level 4
Jun 11, 2021 3:13 PM UTC
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?

No text available
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
kchaurasiya
kchaurasiyaAccepted solution
Level 5
Jun 11, 2021 4:00 PM UTC

Hi Karthick1356,

 

Have you tried in this way 

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

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

2 replies

kchaurasiya
kchaurasiyaAccepted solution
Level 5
Jun 11, 2021 4:00 PM UTC

Hi Karthick1356,

 

Have you tried in this way 

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

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

Translate
Ritesh_Mittal
New Participant
Jun 11, 2021 3:56 PM UTC

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=en

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

Translate