AEM : Access to global values from dialog-clientlib

Avatar

Avatar

infinityskyline

Avatar

infinityskyline

infinityskyline

08-01-2021

Currently, I am storing certain value as in data-attributes in customheaderlibs.html

<div data-sly-use.myjava="MyJava"
     data-score="${myjava.getScore}"
     data-team="${myjava.getTeam}"></div>

and were reading these values by

const iframeContents = document.querySelector('iframe').contentWindow.document.body;
        const configElement = iframeContents.querySelector('div[data-score]');

 

This works fine for certain resolution of a screen. But in smaller viewport such as in iPad where cq dialog opens as a full screen and not as a dialog box, customheaderlibs.html seems to be absent from the DOM. Hence, these data cannot be accessed from javascript on dialog-ready. Is there any way these data can be accessed, may be if passed as query parameter to the granite dialog path? But not sure how to achieve this. 

View Entire Topic

Avatar

Avatar

KiranVedantam1992

Avatar

KiranVedantam1992

KiranVedantam1992

08-01-2021

Hi @infinityskyline,

 

If I understand your query correctly, you are trying to access the HTML elements in JS. Please refer to my answer here.

Hope this helps.

 

Thanks,

Kiran Vedantam