В 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>