获取由JavaScript中作者[AEM]选择的对话框属性值
问题描述:
我想知道如何从作者在给定的下拉列表中获取选定值触摸UI对话框使用javascript进行进一步操作。获取由JavaScript中作者[AEM]选择的对话框属性值
下面是我的javascript我对话框结构
<?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"
sling:resourceType="cq/gui/components/authoring/dialog">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/tabs"
type="nav"/>
<items jcr:primaryType="nt:unstructured">
<General
jcr:primaryType="nt:unstructured"
jcr:title="General Questions"
sling:resourceType="granite/ui/components/foundation/container">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"/>
<items jcr:primaryType="nt:unstructured">
<columns
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<allowed-selections
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/select"
fieldLabel="Allowed Selections"
name="./allowed">
<items jcr:primaryType="nt:unstructured">
<one
jcr:primaryType="nt:unstructured"
text="One"
value="one"/>
<two
jcr:primaryType="nt:unstructured"
text="Two"
value="two"/>
<three
jcr:primaryType="nt:unstructured"
text="Three"
value="three"/>
<four
jcr:primaryType="nt:unstructured"
text="Four"
value="four"/>
</items>
</allowed-selections>
<description/>
<selection-text
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="Selection Text"
name="./selectiontext"/>
</items>
</columns>
</items>
</General>
</items>
</content>
</jcr:root>
在这里,我想取./allowed(下拉)的对话框属性值。
预先感谢您。
答
AEM是一种有一个开箱即用的库feature.If看到 etc文件夹,我们有以下文件
/库/ CQ/GUI /组件/制作/对话框/ dropdownshowhide/clientlibs实现隐藏/显示/dropdownshowhide/js/dropdownshowhide.js
Foundationcontentloaded,改变和选择的事件是基于被取回
参见类名选择器和目标元素选择值有拍摄采样片段
$(document).on("selected", ".dropdownselect", function(e) {
//iterate over e and get element select value
});
$(element).data(“select”)。getValue();
添加类,数据属性和选择作为其在JS,那么你也可以使用选择监听器获取选中下拉值,做你的自定义逻辑
在你的对话框添加类dropdownselect,您可以顶给定然后在变化事件中捕获价值
<allowed-selections
jcr:primaryType="nt:unstructured"sl
sling:resourceType="granite/ui/components/foundation/form/select"
fieldLabel="Allowed Selections"
name="./allowed"
class = "dropdownselect">
我不确定将来其他人的绝对路径是否会有用。您应该对解决方案进行一些扩展,以便以一般方式进行理解。 – jdv
当然。我指的是我们拥有这个文件的默认位置。我将用更多的输入来更新解决方案 – sherry
我保证你在路上的某个人不会在这个位置有这个文件,这使得这个答案对他人不太有用。更不用说这个位置只是某些平台的默认设置。请参阅:https://stackoverflow.com/help/how-to-answer – jdv