context aware configuration inside jquery | Community
Skip to main content
New Participant
June 14, 2020
Solved

context aware configuration inside jquery

  • June 14, 2020
  • 2 replies
  • 1589 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

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

2 replies

joerghoh
Employee
June 14, 2020

Hi,

 

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

 

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.

 

arunpatidar
arunpatidarAccepted solution
New Participant
June 14, 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" />
Arun Patidar