Expand my Community achievements bar.

SOLVED

cq:listener - afteredit listener custom value

Avatar

Level 2

Hi All,

My requirement : I have a component which accepts some text say "#abc" as a dialog property. The current page URL, say "http://localhost:4502/content/xyz.html", has to be appended with the dialog property value as "http://localhost:4502/content/xyz.html#abc" before the page gets refreshed after edit of the dialog. So, when we close the dialog editor the page should get refreshed with the appended URL and not the initial page URL.

Is there a way to define a custom value for the afteredit cq:listener where i can define my javascript logic? or any other approach to achieve this functionality?

Any help is appreciated.

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Level 10

1. have a clientlibs with category cq.authoring.dialog

2. Add a js file with this wrapper code - It defines the base for listener, you should be able to place your code here.

(function ($, $document) {

   

    $document.on("dialog-ready", function() {

        // Dialog is loaded

    });

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

        // Dialog submit event

    });

})($, $(document));

View solution in original post

5 Replies

Avatar

Level 2

would like to implement on both

Avatar

Level 2

I was able to implement it on classic UI using the beforesubmit listener on the dialog, defining the logic using JS. However, could anyone please direct me to the right documentation talking about dialog listeners for Touch UI. A generalized guide may be?

Avatar

Correct answer by
Level 10

1. have a clientlibs with category cq.authoring.dialog

2. Add a js file with this wrapper code - It defines the base for listener, you should be able to place your code here.

(function ($, $document) {

   

    $document.on("dialog-ready", function() {

        // Dialog is loaded

    });

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

        // Dialog submit event

    });

})($, $(document));