Expand my Community achievements bar.

SOLVED

Issue with clientlibs in AEM 6.3 for categories cq.authoring.dialog

Avatar

Level 8

Hi,

I want to write a custom jquery/js function for some hide/show manipulations in dialog.

If I place this in clientlibs folder[having categories String[] cq.authoring.dialog, dependencies String[] granite.jquery] which has js.txt[having name of custom js/jquery file] and the custom file.

If i just put  the below

$(document).ready(function() {

    alert('check');

});

in custom file,

alert is displayed when I refresh the page and not when I open dialog. Trying on this for quite some time now, but no luck. Shouldn't ideally this alert be displayed when I open the dialog rather than on page refresh.

Also, created the clientlibs folder at component level, but still the same behavior.

Not sure what is it that I am doing wrong. Any thoughts on this will be really helpful.

1 Accepted Solution

Avatar

Correct answer by
Level 5

Hi

This is true you will see the alert on page load because all the authoring clientLibs is loading on pageload in authoring mode.So when you load the page all client lib will load that along with your ClientLib, you can not use directly $(document).ready(function() it will show the alert when you load.you have to bind some event with that id.So it will trigger only whrn particular event occur on particular id like onclick below is the sample.

$(document).ready(function(){

    $("p").click(function(){

        alert("The paragraph was clicked.");

    });

});

It will only occur when you click on p tag.

This thread will help you Show hide dialog fields based on selection in AEM 6.3

https://gist.github.com/rjspiker/003cf9eac1e853bb109a

Hope these will Help!

View solution in original post

3 Replies

Avatar

Correct answer by
Level 5

Hi

This is true you will see the alert on page load because all the authoring clientLibs is loading on pageload in authoring mode.So when you load the page all client lib will load that along with your ClientLib, you can not use directly $(document).ready(function() it will show the alert when you load.you have to bind some event with that id.So it will trigger only whrn particular event occur on particular id like onclick below is the sample.

$(document).ready(function(){

    $("p").click(function(){

        alert("The paragraph was clicked.");

    });

});

It will only occur when you click on p tag.

This thread will help you Show hide dialog fields based on selection in AEM 6.3

https://gist.github.com/rjspiker/003cf9eac1e853bb109a

Hope these will Help!

Avatar

Level 8

Hi zeeshank15007365,

Thank you for detailed explanation.

Ya actually am currently working on  Show hide dialog fields based on selection in AEM 6.3 this. Spent close to a day on this, but no luck. Let me post a seperate question on my doubts.

Avatar

Level 10

Files in the category cq.authoring.dialog are supposed to load when authoring mode and will be loaded on page load.

If you are looking to have event on dialog open, correct answer will be to use

$(document).on('dialog-ready', function () {
});