context aware configuration inside jquery

srikanthg212933

14-06-2020

Hi 

I would want to access and read context aware configurations inside Jquery (eg: on dialog ready, inside custom coral dialog).

Could someone let me how could we achieve this ??  any example reference would be very much appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

Arun_Patidar

MVP

14-06-2020

I don't think so you can access CAC inside jquery directly. What you can do is, you can create empty div or json object with CAC value and the later access those values in jquery.

 

e.g.

<script>
var cacObj;
cacObj.key1=cacVal1;
cacObj.key2=cacVal2;

....

</script>

 

 

or 

<div data-cacKey1="cacVal1" data-cacKey2="cacVal2" />

Answers (1)

Answers (1)

Jörg_Hoh

Employee

14-06-2020

Hi,

 

when you refer to Context-Aware-Configuration, do you mean this: https://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configurati...

 

If yes: jquery is executed within the browser, while CAC is executed on the server-side. Mixing both approaches directly is not possible. The only chance you have is to execute the CAC lookups on the server, and include the result into JSON or the generated HTML, and use this data then inside javascript/jquery.