AEM 61 - Get reference of Parent Parsys Editable in Component Dialog

Goal


Sample code to get the reference of parent parsys component editable in TouchUI

Demo | Package Install



Solution


1) Login to CRXDE Lite (http://localhost:4502/crx/de) and create folder /apps/eaem-parsys-ref-in-component-dialog

2) Create node /apps/eaem-parsys-ref-in-component-dialog/clientlib of type cq:ClientLibraryFolder and add a String property categories with value cq.authoring.dialog

3) Create file (nt:file) /apps/eaem-parsys-ref-in-component-dialog/clientlib/js.txt and add

                       parsys-ref.js

4) Create file (nt:file) /apps/eaem-parsys-ref-in-component-dialog/clientlib/parsys-ref.js and add the following code

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

    function showParsysPath(){
        var dialog = gAuthor.DialogFrame.currentDialog,
            parent = dialog.editable.getParent();

        if(!parent){
            return;
        }

        showMessage("Parent", parent.path);
    }

    function showMessage(title, message){
        $(window).adaptTo('foundation-ui').prompt(title, message, "default", [{
            primary: true,
            text: Granite.I18n.get('OK')
        }]);
    }
}($(document), Granite.author));

2 comments: