-
-
Save Surajkamdi/254f660e094e36c2738bed9aeefef4a0 to your computer and use it in GitHub Desktop.
AEM 6.x: Reload the page when the user switches layers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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