Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AEM: Add JavaScript (including events) to AEM loaded on editor.html. Solution: Create clientlib with category "cq.authoring.dialog". Exemplary usage: Reload page if layer changes.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
categories="[cq.authoring.dialog]"/>
(function () {
'use strict';
function onModeChange() {
location.reload();
}
function reloadOnModeChange() {
document.querySelectorAll('.js-editor-LayerSwitcherTrigger').forEach(function (element) {
element.addEventListener('click', onModeChange);
});
}
reloadOnModeChange();
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.