Skip to content

Instantly share code, notes, and snippets.

@kevinweber
Last active August 24, 2022 02:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kevinweber/925a94d3ee148104ca5e44f5ddd10946 to your computer and use it in GitHub Desktop.
Save kevinweber/925a94d3ee148104ca5e44f5ddd10946 to your computer and use it in GitHub Desktop.
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