Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

is that possible to Read the value from sightly and set through jQuery

Avatar

Level 4

Hi All,

i have a requiremnt that read the value from sightly and set through jquery. If we have a alternate way kindly let me know.

Reading the value from author node and displaying on preview/publisher mode

code snippet:

var a = ${pageProperties['pagecontent/offertitle/title']}

jQuery("#title").text(a);

3 Replies

Avatar

Level 4

Hi,

The variable value you read in sightly can be set in a hidden html input field on the page and the same field can then be accessed in jquery.

Avatar

Community Advisor

Hi,

You can directly used the variable in script tag in sightly using sightly context based on your requirement. Or you can also try using JS API as mentioned by smacdonald2008

<script>

var variable = '${properties.variablename @ context="scriptString"}'; // This can be used in javascript included after it as it is available as global variable

</script>

Hope this helps !