Skip to content

Instantly share code, notes, and snippets.

@Surajkamdi
Forked from badvision/reloadOnLayerSwitch.js
Created May 17, 2021 14:06
Show Gist options
  • Save Surajkamdi/254f660e094e36c2738bed9aeefef4a0 to your computer and use it in GitHub Desktop.
Save Surajkamdi/254f660e094e36c2738bed9aeefef4a0 to your computer and use it in GitHub Desktop.
AEM 6.x: Reload the page when the user switches layers
// This must be in a client library with the category cq.authoring.editor.hook
/* global Granite, jQuery, document */
(function ($, channel) {
'use strict';
$(function () {
var loadedTime = new Date();
channel.on('cq-layer-activated', function (event) {
if (event.prevLayer && event.layer !== event.prevLayer) {
var eventTime = new Date();
if (event.prevLayer !== 'Annotate' && event.layer !== 'Annotate' && (eventTime - loadedTime) > 1500) {
location.reload();
}
}
});
});
})(Granite.$, jQuery(document));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment