Expand my Community achievements bar.

SOLVED

Component specific dialog listeners in AEM 6.4/6.5

Avatar

Level 10

Hello All,

 

Is there a way to have component specific dialog listeners ? I have a clientlibrary created with categories cq.authoring.dialog and a function on save of dialog. This however gets invoked on every dialog save. How could i make it component specific?

Usecase would be i want to validate if the droptarget has an image set


$(document).on("click", ".cq-dialog-submit", function (e) {

alert("hello !on submit");
});



1 Accepted Solution

Avatar

Correct answer by
Level 10

@Kishore_Kumar_  Used something like this with validate at droptarget and it applied to that component itself on 64..Thanks for the help. I would definitely try your approach on 65 since i like to use dialog functions

(function(ns, $, $document){
$(window).adaptTo("foundation-registry").register("foundation.validation.validator",{

selector: "[data-validation='xxx-validation']",

 

});

});

View solution in original post

5 Replies

Avatar

Community Advisor

Hi,

 

We can make use of extraClientlibs or includeclientlibs to load a dialog specific clientlibs.

 

https://wcmaem.blogspot.com/2016/08/how-to-load-touchui-dialog-specific.html?m=1

Avatar

Level 10

Thanks for the response but i am not sure i understand. Is this compatible with 6.4 or 6.5? And my use case would be to validate if on save of the dialog, the droptarget has an image or not set for that component.

Update putting in extraclientlibs in 6.4 just brings up validation for every component dialog save @Kishore_Kumar_ 

 

please let me know

Avatar

Community Advisor

Hi @NitroHazeDev ,

 

We have to use custom clientlibs category name (not cq.authoring.dialog) and add in extraClientlibs property.

Avatar

Level 10

I thought that did it but clearing the cache that did not work. Set the extraclientlibs at cq:dialog node with another clientlibrary and also added the script to the JS .But on save the dialog is invoked for any component not just the one we want to @Kishore_Kumar_ 

I am on 6.4

Avatar

Correct answer by
Level 10

@Kishore_Kumar_  Used something like this with validate at droptarget and it applied to that component itself on 64..Thanks for the help. I would definitely try your approach on 65 since i like to use dialog functions

(function(ns, $, $document){
$(window).adaptTo("foundation-registry").register("foundation.validation.validator",{

selector: "[data-validation='xxx-validation']",

 

});

});