AEM 6.4.3-验证在珊瑚3触摸UI对话框中不起作用

时间:2019-03-05 22:12:59

标签: aem aem-6

在AEM 6.4.3,coral-3 touch-ui对话框中,我有第一个下拉菜单,其中包含三个值[x,y,z],第二个下拉菜单中包含这些值[abc,def,ghk ]。我的要求是,当我在第一个下拉列表中选择值[y]时,我想禁用第二个下拉列表并将值设置为[def]。在第一个下拉菜单中选择[y]时,作者不能更改第二个下拉菜单的值(默认为[def])。

以上提到的要求在AEM 6.3.2中与以下提到的客户端库一起正常工作,但在6.4.3 Coral-3中不起作用。基本上,在警报消息中,first-select的值是未定义的。

    (function(){
  var $doc = $(document);
  var $first, $second;
  $doc.on('foundation-contentloaded', function(e) { // 'foundation- 
  contentloaded' triggered when dialog is ready
    $dialog = $(e.target); 
    firstSelect = $dialog.find('#first-dropdown').data('select'); 
    alert('firstSelect---'+firstSelect); 
    secondSelect = $dialog.find('#second-dropdown').data('select');

    function toggleSecond(firstVal){
      if(firstVal === 'y'){
        secondSelect._select('def', 'def');
        secondSelect.set('disabled', true)
        secondSelect.$element.find('select').removeAttr('disabled');
      }
      else {
        secondSelect.set('disabled', false)
      }
    }

    // run when dialog opens
    toggleSecond(firstSelect.getValue());

    firstSelect.on('selected', function(e){
      toggleSecond(e.selected);
    })
  });
})();



<?xml version="1.0" encoding="UTF-8"?>
<jcr:root
    xmlns:jcr="http://www.jcp.org/jcr/1.0"
    xmlns:cq="http://www.day.com/jcr/cq/1.0"
    xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    xmlns:sling="http://sling.apache.org/jcr/sling/1.0" 
    jcr:primaryType="nt:unstructured" 
    jcr:title="Example Dialog"
    sling:resourceType="cq/gui/components/authoring/dialog"
    extraClientlibs="[dropdown-author-clientlib]">
    <content jcr:primaryType="nt:unstructured"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">
            <column jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/container">
                <items jcr:primaryType="nt:unstructured">
                    <first jcr:primaryType="nt:unstructured" fieldLabel="First" id="first-dropdown" name="./first" sling:resourceType="granite/ui/components/foundation/form/select">
                        <items jcr:primaryType="nt:unstructured">
                            <default jcr:primaryType="nt:unstructured" text="(default)" value="" />
                            <x jcr:primaryType="nt:unstructured" text="x" value="x" />
                            <y jcr:primaryType="nt:unstructured" text="y" value="y" />
                            <z jcr:primaryType="nt:unstructured" text="z" value="z" />
                        </items>
                    </first>
                    <second jcr:primaryType="nt:unstructured" fieldLabel="second" id="second-dropdown" name="./second" sling:resourceType="granite/ui/components/foundation/form/select">
                        <items jcr:primaryType="nt:unstructured">
                            <def jcr:primaryType="nt:unstructured" text="def" value="def" />
                            <ghi jcr:primaryType="nt:unstructured" text="ghi" value="ghi" />
                            <abc jcr:primaryType="nt:unstructured" text="abc" value="abc" />
                            <default jcr:primaryType="nt:unstructured" text="(default)" value="" />
                        </items>
                    </second>
                </items>
            </column>
        </items>
    </content>
</jcr:root>

0 个答案:

没有答案