Skip to content

Instantly share code, notes, and snippets.

@besimhu
Forked from kevinweber/.content.xml
Created November 14, 2021 23:49
Show Gist options
  • Save besimhu/d8d6cfa07950e9f3ed0cf68a9ddfebf7 to your computer and use it in GitHub Desktop.
Save besimhu/d8d6cfa07950e9f3ed0cf68a9ddfebf7 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