Force refresh on Edit/Preview mode change? | Community
Skip to main content
eric_estes
Level 2
November 6, 2015
Solved

Force refresh on Edit/Preview mode change?

Is there a way to force the current page to refresh when switching between Edit and Preview modes? This is to ensure that logic that checks against the current mode value runs as expected.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
smacdonald2008
smacdonald2008Accepted solution
Level 10
November 9, 2015

This has been shown in an EKS demo. If you look at the EKS wiki page [0]. There should be a recording for a Touch UI session and this was discussed there. 

A very basic code that does something similar is below. Obviously this will need to be tested and ensured that it works, but it gives the general idea. 

(function ($, channel) {
    'use strict';
    $(function () {
        channel.on('cq-layer-activated', function (event) {

            var pageUrl = window.location.href;
            var ANNOTATE_LAYER = 'Annotate';
            if ( event.prevLayer && event.layer !== event.prevLayer
                        && event.layer != ANNOTATE_LAYER  && event.prevLayer != ANNOTATE_LAYER ) {
                    location.reload();
                }
        });
    });
})(Granite.$, jQuery(document));

[0]https://wiki.corp.adobe.com/x/mIc1N

5 replies

smacdonald2008
Level 10
November 9, 2015

HI  - This has been shown in an EKS demo. If you look at the EKS wiki page [0]. There should be a recording for a Touch UI session and this was discussed there. 

A very basic code that does something similar is below. Obviously this will need to be tested and ensured that it works, but it gives the general idea. 

(function ($, channel) {
    'use strict';
    $(function () {
        channel.on('cq-layer-activated', function (event) {

            var pageUrl = window.location.href;
            var ANNOTATE_LAYER = 'Annotate';
            if ( event.prevLayer && event.layer !== event.prevLayer
                        && event.layer != ANNOTATE_LAYER  && event.prevLayer != ANNOTATE_LAYER ) {
                    location.reload();
                }
        });
    });
})(Granite.$, jQuery(document));

[0]https://wiki.corp.adobe.com/x/mIc1N

Translate
smacdonald2008
smacdonald2008Accepted solution
Level 10
November 9, 2015

This has been shown in an EKS demo. If you look at the EKS wiki page [0]. There should be a recording for a Touch UI session and this was discussed there. 

A very basic code that does something similar is below. Obviously this will need to be tested and ensured that it works, but it gives the general idea. 

(function ($, channel) {
    'use strict';
    $(function () {
        channel.on('cq-layer-activated', function (event) {

            var pageUrl = window.location.href;
            var ANNOTATE_LAYER = 'Annotate';
            if ( event.prevLayer && event.layer !== event.prevLayer
                        && event.layer != ANNOTATE_LAYER  && event.prevLayer != ANNOTATE_LAYER ) {
                    location.reload();
                }
        });
    });
})(Granite.$, jQuery(document));

[0]https://wiki.corp.adobe.com/x/mIc1N

Translate
Lokesh_Shivalingaiah
Level 10
November 9, 2015

Yes.. this is for classic UI when you use sidekick

Translate
eric_estes
Level 2
November 9, 2015

edubey wrote...

You can add this piece of code

  1. <script>
  2. CQ.WCM.launchSidekick("${currentPage.path @ context='uri'}", {
  3. propsDialog: "${wcmInit.dialogPath @ context='uri'}",
  4. locked: ${currentPage.locked @ context="scriptString"},
  5. previewReload: "true"
  6. });
  7. </script>

 

 

Is that only for the classic ui, not the touch ui?

Translate
edubey
Level 10
November 7, 2015

You can add this piece of code

<script> CQ.WCM.launchSidekick("${currentPage.path @ context='uri'}", { propsDialog: "${wcmInit.dialogPath @ context='uri'}", locked: ${currentPage.locked @ context="scriptString"}, previewReload: "true" }); </script>
Translate