user2771627
user2771627

Reputation: 11

How to pass a JavaScript variable to an AEM sightly component?

I know that we can pass parameters from Sightly HTML to a WCMUse class or a Sightly-JS but I want to do the other way around. I need to access a specific JS variable from the sightly html file. This is a plain JS which is not using JavaScript Use-Api and resides at the sightly component level. Is there a way to achieve this? any pointers would be of great help.

Upvotes: 0

Views: 2460

Answers (1)

rakhi4110
rakhi4110

Reputation: 9281

You are confusing client side script with server side script. JavaScript runs on the browser and is not available to Sightly, since Sightly runs on the server.

The only way you can access JavaScript variable values on the server is by making an AJAX request and passing the variable's value as a parameter to the server.

Upvotes: 3

Related Questions