-
Notifications
You must be signed in to change notification settings - Fork 33
Author Watch
Chris Millar edited this page Jun 24, 2020
·
2 revisions
Author watch is a simple tool to detect AEM authoring changes and execute a list of javascript functions against the DOM parent element that was changed.
It was created to:
- Avoid the heavy use of
REFRESH_PAGE
to re-execute javascript. - Avoid writing author-related javascript in visitor-facing code.
- Avoid the use of MutationObserver in visitor-facing code.
<sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html">
<sly data-sly-test="${!wcmmode.disabled}" data-sly-call="${clientlib.js @ categories='dx.admin.author'}"></sly>
</sly>
const initMyCoolThing = (element) => {
console.log('my cool thing was edited');
};
window.dx.author.watch.registerFunction(initMyCoolThing);
(does this count as a step three?)