В ContextHubJQ не определена ошибка [AEM 6.4.5, ContextHub] - PullRequest
0 голосов
/ 15 апреля 2020

Получение Uncaught ReferenceError: ContextHubJQ is not defined на моем экземпляре автора AEM, и я не знаю, как отследить эту ошибку.

  • Запуск AEM 6.4.5.
  • Я добавил следующее два ресурса в самом шаблоне самой страницы:
<sly data-sly-call="${clientLib.js @ categories='granite.utils,granite.jquery'}"
     data-sly-unwrap/>
<sly data-sly-test="${!head.isPublic}" data-sly-resource="${'contexthub' @ resourceType='granite/contexthub/components/contexthub'}" />
  • Я проверил localalstorage. ContextHubPersistence инициализируется.
  • В представлении редактора для страницы отображается меню Таргетинг , что означает, что приведенные выше сценарии работают.
  • Я пошел на https://MY_AEM_SERVER/libs/granite/ui/content/dumplibs.rebuild.html и перестроил все клиентские библиотеки.
  • Я сбросил кэш диспетчера.
  • Я дважды перезагрузил сам сервер.
  • У меня также включены сегменты CH в моем конфигурация для проекта.
  • У меня включен интерфейс CH в службе Adobe Granite ContextHub (PID: com.adobe.granite.contexthub.impl.ContextHubImpl)
  • У меня есть настройка конфигурации CH с правильные режимы пользовательского интерфейса и конфигурации магазина. (работает на моем локальном экземпляре - эти ошибки находятся на моем сценическом сервере)

Он отлично работает на моем локальном экземпляре, т.е. в режиме автора preview отображается небольшое меню аудитории. Действительно потерян здесь, и не уверен, где go отсюда ...

Этот фрагмент является источником ошибки. Он находится на странице, получая инъекцию из тега sly:

<script src="/etc/cloudsettings/default/contexthub.kernel.js" type="text/javascript"></script><script type="text/javascript">
                (function($) {
                    'use strict';

                    /* options */
                    /**
                     * @type InjectContextHubOptions
                     */
                    var options = {};

                    /* where to include ContextHub's UI */
                    var injectWindow = window.top;

                    try {
                        /* if window.top contains 'ContextHubEmbedding' flag, use current window instead of window.top */
                        if (window.top.hasOwnProperty('ContextHubEmbedding') === true) {
                            injectWindow = window;
                        }
                    } catch(error) {
                        // if window.top is not reachable for security reasons (like page embedded into an iframe on a different domain), use current window.
                        injectWindow = window;
                    }

                    /* is ContextHub UI loaded from another iframe? then hide it by default (event listeners will display it when requested) */
                    var isEmbedded = injectWindow !== window;
                    var visibility = isEmbedded ? 'none' : 'block';

                    /* display ContextHub immediately if it's embedded on same page as ContentFinder */
                    if (isEmbedded && $('#cq-cf-wrapper', injectWindow.document).length) {
                        /* inject container to a page which includes ContextHub and not to top window */
                        injectWindow = window;
                        visibility = 'block';
                        options['zIndex'] = 10000;
                    }

                    /*
                     * coralui3 related includes:
                     * http://localhost:4502/libs/granite/ui/content/dumplibs.test.html?categories=coralui3
                     */
                    var scripts = [
                        "/etc/cloudsettings/default/contexthub.ui.js",
                        "/etc.clientlibs/clientlibs/granite/typekit.js",
                        "/etc.clientlibs/clientlibs/granite/utils.js",
                        "/etc.clientlibs/clientlibs/granite/jquery/granite.js",
                        "/etc.clientlibs/clientlibs/granite/moment.js",
                        "/etc.clientlibs/clientlibs/granite/coralui3.js"
                    ];

                    var styles = [
                        "/etc.clientlibs/clientlibs/granite/coralui3.css",
                        "/etc/cloudsettings/default/contexthub.styles.css"
                    ];

                    $.extend(options, {
                        address: "/etc/cloudsettings/default/contexthub.ui.html",
                        display: visibility
                    });

                    window.injectContextHubUI(injectWindow.document, ContextHub, scripts, styles, options, function(UI, options) {
                        /* call it on parent ready, otherwise rarely window.document.body won't be ready due to race condition! */
                        $(window.document).ready(function() {
                            var pageContainer = UI.Properties.get('PAGE_CONTAINER') || $(window.document.body);
                            var zIndex = options.zIndex || UI.Properties.get('CONTAINER_UI_Z_INDEX') || 890;

                            UI.Properties.set('CONTAINER_UI_Z_INDEX', zIndex);
                            UI.Properties.set('PAGE_CONTAINER', pageContainer);

                            /* if document was not yet ready, set the page container once again later */
                            if (pageContainer.length === 0) {
                                $(function() {
                                    UI.Properties.set('PAGE_CONTAINER', $(window.document.body));
                                });
                            }

                            if (isEmbedded) {
                                /* hide ContextHub container on iframe unload - to get rid of white gap that is visible during page reload */
                                window.onbeforeunload = function() {
                                    /* catch the errors in case objects will get destroyed before code will be executed */
                                    try {
                                        $(ContextHub.UIFrame).hide();
                                        var pageContainer = UI.Properties.get('PAGE_CONTAINER') || $('');
                                        pageContainer.css('transition', '');
                                        pageContainer.css('top', UI.Properties.get('IFRAME_TOP_MARGIN'));
                                    } catch (error) {
                                        console.error("Error while unloading the page: ", error);
                                    }
                                };
                            }
                        });
                    });

                }(ContextHubJQ));
            </script>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...