DOM Manipulation in sightly using javascript | Community
Skip to main content
New Participant
Aug 1, 2018 11:13 AM UTC

DOM Manipulation in sightly using javascript

Is it possible to achieve DOM manipulation inside use function by accessing document and window objects? If not do we need to create a separate js file to achieve this? Currently in my component I have one JS file inside clientlibs which only deals with DOM manipulation and the other one which uses "use" function. So is this the right approach?

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

6 replies

arunpatidar
New Participant
Aug 1, 2018 12:57 PM UTC

Yes, you can manipulation of DOM using clientlibs.

Note : data-sly-use is use to intantiate Java/Js object for for backend functionality.

Translate
Arun Patidar
smacdonald2008
Level 10
Aug 1, 2018 1:47 PM UTC

WHen working with HTL components - you can use JS - as shown here:

Adobe Experience Manager Help | Creating an Adobe Experience Manager HTML Template Language component that uses JavaScri…

Perform your document object calls within JS.

Translate
New Participant
Aug 2, 2018 6:23 AM UTC

The example in the link has a java object ("hello") which is used to retrieve message and another script.js file in clientlibs which does all the DOM manipultaion. But in my case I have a js file which uses sightly use (fucntion() {....}) i.e Javascript use API for retrieving message and another script.js file in clientlibs which does DOM manipulation. So there are two JS files for a component.

So can we do this? Or can I call the document object inside the sightly use(function(){})?

Translate