Expand my Community achievements bar.

SOLVED

Add a custom class to AEM dialog

Avatar

Level 2

Hi Team, 

I am calling a on click event of cq-dialog-submit to perform custom payload for my multifield. Here I want to add a custom class to root element of dialog, so that I can call cq-dialog-submit of my component dialog only.

I added like below in screenshot, but custom class and dialog submit btn lies in different divs.

 

gskittu_0-1675837976839.png

 

gskittu_1-1675838073253.png

Can u suggest me to how to get this element custom-class.cq-dialog-submit 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

I think then you need to add class/data-attribute from content to form attribute on dialog load.

 



Arun Patidar

View solution in original post

8 Replies

Avatar

Community Advisor

Hi @gskittu ,

 

One way to achieve this is through jQuery. Basically you need to find granite class's parent's sibling's child and then trigger submit call.

 

You can check below links-

http://net-informations.com/jq/iq/parent.htm

https://stackoverflow.com/questions/16997072/how-to-select-parents-siblings-children

 

Thanks,

Ritesh Mittal

 

Avatar

Level 2

Hi Ritesh, Thanks for your reply. Getting granite class's parent's sibling's child is happened only when we click on dialog submit

Avatar

Community Advisor

you must use extraClientlibs instead of creating clientlibs cq.authoring.dialog category,

This will make sure the clientlib is loaded only for your dialog.

Example 

Clientlib https://github.com/arunpatidar02/aemaacs-aemlab/blob/f96ce5316dfa4798c72d2e87d3a0b41fc49791a4/ui.app... 

used only in https://github.com/arunpatidar02/aemaacs-aemlab/blob/f96ce5316dfa4798c72d2e87d3a0b41fc49791a4/ui.app... 



Arun Patidar

Avatar

Level 2

Hi Arun, Thanks for your reply. I have already added extraclientlibs , this clientlibs loads only when dialog opened, that's ok but clientlibs are staying on site even after closing the dialog, this is causing other dialogs in same page getting effected as we used click event of cq-dialog-submit

Avatar

Correct answer by
Community Advisor

Hi,

I think then you need to add class/data-attribute from content to form attribute on dialog load.

 



Arun Patidar

Avatar

Level 2

Thanks Arun, 
It worked, added class from content to form attribute on dialog load

Avatar

Level 1

how did you add the class from content to form attribute here? can you please share the example code?
@arunpatidar