【问题标题】:AEM 6.1 missing CQ javascript functionAEM 6.1 缺少 CQ javascript 函数
【发布时间】:2016-11-01 15:05:51
【问题描述】:

我收到以下错误:

VM13430 editor.js:25678Uncaught TypeError: Cannot read property 'shared' of undefined

在 Granite UI 中的 AEM 6.1 中以作者模式加载页面时。它在以下行失败:

var isLockOwner = true;
    if(info.status.isLocked){
        isLockOwner = ns.ContentFrame && ns.ContentFrame.contentWindow.CQ.shared.User.data.userID === info.status.lockOwner;
    }

在调试ns.ContentFrame.contentWindow.CQ 时,缺少“CQ”。 在检查 Geometrixx 演示内容时,'CQ' 是一个函数,我假设是 jquery 的 jQuery 分辨率。

因此,如果页面被锁定,我将无法解锁。虽然如果在页面网格视图中我可以解锁页面。

如何确保我可以为 'ns.ContentFrame.contentWindow' 加载 CQ?

【问题讨论】:

  • 你加载了哪些客户端库?他们有什么关系。您是否偶然在您的客户端库中“嵌入”了任何内容?
  • @ub1k,谢谢,您为我指明了正确的方向。在检查演示 Geometrixx 站点时,我似乎缺少“嵌入”。

标签: jquery aem


【解决方案1】:

在 clientlibs 目录的.content.xml 中添加以下内容:

embed="[underscore,granite.shared,cq.shared,jquery.jcarousel,cq.foundation,cq.foundation-main,jquery-ui,cq.jquery.ui,personalization,personalization.core,personalization.core.kernel,personalization.clientcontext.kernel,personalization.stores.kernel,personalization.kernel,personalization.clientcontext,personalization.stores,cq.social.tagging,cq.ckeditor,cq.social.scf,cq.social.author.hbs.message,cq.social.author.hbs.messagebox,cq.social.author.hbs.composemessage,cq.social.author.hbs.userchooser,cq.social.author.hbs.comments,cq.social.author.hbs.forum,cq.social.author.hbs.journal,cq.social.author.hbs.rating,cq.social.author.hbs.qna,cq.social.author.hbs.voting,cq.social.author.hbs.reviews,cq.social.author.hbs.search,cq.social.author.hbs.calendar,cq.social.hbs.socialgraph,cq.social.calendar,cq.social.calendar.eventbasics,cq.social.calendar.fullcalendar,cq.social.author.hbs.socialgraph.following,cq.social.author.hbs.activitystreams,cq.social.commons.infiniscroll]"

【讨论】:

  • 我讨厌 adobe 隐藏了一切。你的回答太棒了。 adobe 中的每个 javascript 对象现在都在工作。永远不要期望那样。谢谢
  • 哦,对不起,我认为它有帮助,但它只是 devolper 模式下的 chrome 浏览器。我仍然没有到达我的 javascript 文件中的 CQ 对象
【解决方案2】:

基本上这里的问题是您需要包含一个 clientLib - cq.shared

根据 Adob​​e : " 编辑器客户端库假定存在 cq.shared 命名空间 在内容页面中,如果不存在 JavaScript 错误 Uncaught TypeError: Cannot read property 'shared' of undefined 将导致。

所有示例内容页面都包含 cq.shared,因此基于它们的任何内容都会自动包含 cq.shared。但是,如果您决定从头开始创建自己的内容页面而不基于示例内容,则必须确保包含 cq.shared 命名空间。 "

由于某种原因,嵌入对我不起作用,但是从基本 html 调用 clientLib 似乎可以工作

<sly data-sly-use.clientlib="granite/sightly/templates/clientlib.html" />
<sly data-sly-call="${clientlib.js @ categories='cq.shared'}"/>

【讨论】:

  • 一点补充,嵌入没有工作,但在花了更多时间之后,添加 dependencies="cq.shared" 工作
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-22
  • 2019-02-23
  • 1970-01-01
  • 2014-07-24
相关资源
最近更新 更多