cq:listener - afteredit listener custom value | Community
Skip to main content
Level 2
Jan 4, 2018 8:42 AM UTC
Solved

cq:listener - afteredit listener custom value

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
edubey
edubeyAccepted solution
Level 10
Jan 4, 2018 10:49 AM UTC

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));

​

5 replies

S_BhavyaAuthor
Level 2
Jan 4, 2018 10:54 AM UTC

Thank you!! that works!

Translate
edubey
edubeyAccepted solution
Level 10
Jan 4, 2018 10:49 AM UTC

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));

​

Translate
S_BhavyaAuthor
Level 2
Jan 4, 2018 10:28 AM UTC

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?

Translate
S_BhavyaAuthor
Level 2
Jan 4, 2018 10:06 AM UTC

would like to implement on both

Translate
edubey
Level 10
Jan 4, 2018 10:04 AM UTC

classic or touch ui?

Translate