【问题标题】:CQ5 nested multi-field with select option带有选择选项的 CQ5 嵌套多字段
【发布时间】:2016-01-25 17:43:54
【问题描述】:

我需要将编辑器在对话框面板中的textfield 中写入的值添加到<select> 选项中。我已经为对话框组件创建了多字段选项,但不确定如何在 <select> 中获取值。

我正在使用多字段的 JS 小部件,您可以找到它here。我知道多字段 JS 应该返回一个 JSON 选项数组,我该如何实现呢?

这是我的 XML 标记:

<developer
    jcr:primaryType="cq:Widget"
    title="Data"
    xtype="panel">
    <items jcr:primaryType="cq:WidgetCollection">
        <developer
            jcr:primaryType="cq:Widget"
            fieldDescription="Click the '+' to add a new data"
            fieldLabel="Dev Data"
            name="./devdata"
            xtype="multifield">
            <fieldConfig
                jcr:primaryType="cq:Widget"
                xtype="devprofile"/>
        </developer>
    </items>
</developer>

为多字段添加文本字段的 JavaScript

this.developerName = new CQ.Ext.form.TextField({
    fieldLabel : "Developer's Name",
    allowBlank: true,
    width : 400,
    listeners : {
        change : {
            scope : this,
            fn : this.updateHidden
        },
        dialogclose : {
            scope : this,
            fn : this.updateHidden
        }
    }
});
this.add(this.developerName);

还有标记:

<c:if test="${not(empty(developerName))}">
    <select id="use-names" class="js-example-basic-multiple">
        <option>Example</option>
        <option>${developerName}</option>
    </select>
</c:if>

如果您需要更详细的分享,请告诉我。

【问题讨论】:

    标签: javascript json aem


    【解决方案1】:

    ACS commons 有很好的自定义多字段工作示例。看看https://adobe-consulting-services.github.io/acs-aem-commons/features/widgets.html

    只需将 textarea 替换为您的下拉菜单,您就会拥有所需的内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-07
      • 1970-01-01
      • 2013-03-27
      • 2023-02-14
      • 2016-08-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多