Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How can I add action to button in componnet

Avatar

Former Community Member

Hi,

How can I add action to button in component. Button is not selecting from inside the component in aem 6.2

please find below img for reference.

1234699_pastedImage_1.png

Thanks in advance.

Sandhya.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi Sandya

     You can write a click event associated with your button . (I assume the button you are referring here should be the one labelled Convert ? )

     Add a class or div id to you button's HTML and as smacdonald2008​ Scott mentioned , write a javascript/jquery function for the click event associated with the class or div .

This may help you https://api.jquery.com/click/

PS:- Above solution is in an assumption that you are looking to attach an event to your button in your page . (Since your query doesn't have much details to explore more )

Thanks

Veena

View solution in original post

6 Replies

Avatar

Level 10

If you are using HTL - then use JavaScript to drive an action on a button in the component. Using HTL - you can use a ClientLib that contains the JS file - as shown in this article:

Scott's Digital Community: Creating an AEM HTL component that uses JavaScript

Avatar

Correct answer by
Community Advisor

Hi Sandya

     You can write a click event associated with your button . (I assume the button you are referring here should be the one labelled Convert ? )

     Add a class or div id to you button's HTML and as smacdonald2008​ Scott mentioned , write a javascript/jquery function for the click event associated with the class or div .

This may help you https://api.jquery.com/click/

PS:- Above solution is in an assumption that you are looking to attach an event to your button in your page . (Since your query doesn't have much details to explore more )

Thanks

Veena

Avatar

Community Advisor

Hi Sandhya,

It's same as normal html and js. if you want the button to be functional then you need to specify the logic in js.

and use clientlib to call the js into your component and js function into the html file.

onclick Event

Please check above link. you will get to know about it.

~ Prince

Avatar

Level 3

Hey Scott,

Can we put the onclick / click end in our client lib ?

Avatar

Level 10

Yes - you can put JS that handles a click event in a client lib.

This article will help you -- Scott's Digital Community: Creating an AEM HTL component that uses JavaScript