【问题标题】:How to getParent().getNode().getProperty("jcr:title") in JavaScript?如何在 JavaScript 中 getParent().getNode().getProperty("jcr:title")?
【发布时间】:2019-07-24 13:15:46
【问题描述】:

在 AEM 中,我正在拦截组件的 cq:dialog 提交,因为我需要修改一些参数,然后才能将它们发送到默认的 POST.jsp

以下代码适用于组件!! jcr_root/apps/gare_rfi/clientlibsAuthor/js/dialogSubmit_editorialGare.js

(function(document, $, ns) {
"use strict";
$(document).on("click", ".cq-dialog-submit", function(e) {
var $form = $(this).closest("form.foundation-form");  
$form.find("[name='./tipologia']").val("this_works"); 
var tipologia = $form.find("[name='./tipologia']").val(); 
console.log(tipologia);
});
})(document, Granite.$, Granite.author);

问题是我需要获取组件所在页面的属性,以及该页面父级的属性。

上面的JS文件包含在cq:dialog - content.xml:

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="nt:unstructured"
    jcr:title="Editorial Gare"
    sling:resourceType="cq/gui/components/authoring/dialog"
    extraClientlibs="[gare_rfi.editorialGareAuthor]">
..........

换句话说,我希望有正确的表达方式来执行以下操作:

console.log( this.getPage().getParent().getProperty("jcr:title") );

ps。我不想使用ajax。 谢谢

pps。 http://blogs.adobe.com/experiencedelivers/experience-management/htl-javascript-use-api/ 有用! 使用(函数(){ var title = currentPage.properties.get(“jcr:title”); “使用”是什么意思? 无论如何,我无法将“使用功能”与我的 extraClientlib 合并

【问题讨论】:

    标签: javascript jquery aem crx


    【解决方案1】:

    Clientlibs 在浏览器上运行。您尝试使用的 AEM/JCR api 在您当前的上下文中不可用。所有这些都只能在服务器上工作。不幸的是,您可能不得不使用 ajax [我阅读了 PS] 或编写过滤器。

    【讨论】:

    • blogs.adobe.com/experiencedelivers/experience-management/… 有效! use(function () { var title = currentPage.properties.get("jcr:title"); "use" 是什么意思?反正我不能将 "use function" 与我的 extraClientlib 合并
    • 这是一个服务器端脚本,clientlib是一个基于浏览器的脚本。对话框单击时没有服务器端脚本的挂钩
    猜你喜欢
    • 2017-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-16
    相关资源
    最近更新 更多