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

context aware configuration inside jquery

Avatar

Level 3

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.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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" />

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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" />

Avatar

Employee Advisor

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.