gpt4 book ai didi

xml - 带有 bool 表达式的 AEM XML 必需属性

转载 作者:行者123 更新时间:2023-12-04 09:42:37 26 4
gpt4 key购买 nike

我想知道,是否可以将替代文本设置为非强制性,同时选中“图像是装饰性的”?我正在使用 AEM 6.5,这是代码。

<decorative jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/checkbox" checked="${not empty cqDesign.isDecorative ? cqDesign.isDecorative : false}" fieldDescription="Check if the image should be ignored by assistive technology and therefore does not require an alternative text. This applies to decorative images only."
name="./isDecorative" text="Image is decorative" uncheckedValue="false" value="{Boolean}true" />

<alt jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/textfield" fieldDescription="For visually impaired users using screen readers. Describe the functionality of the image or what you see in the image. Don't include 'image of', 'picture of', etc. If the image is purely graphical, select 'Image is decorative'."
fieldLabel="Alt text" name="./alternativeText" required="${not empty cqDesign.isDecorative ? false : cqDesign.isDecorative}" />


我知道 AEM 支持像 required="{Boolean} true" 这样的表达式或者干脆 required="false" .我已经尝试过(如上所示) required="${not empty cqDesign.isDecorative ? false : cqDesign.isDecorative}" ,但 id 不起作用。

最佳答案

@Michal - 你需要为此写下 js 代码,
它应该在创作时加载(extraClientlibs)
并在复选框更改时,更新已提交的替代文本(强制/非)
sample 在这里-

(function(document, $, Coral) {
"use strict";

// when dialog gets injected
$(document).on("foundation-contentloaded", function(e) {
// if there is already an initial value make sure the according target element becomes visible
makeMandatoryAAlt($(".makemandatory", e.target));

});

// To mandatory/non figure
$(document).on("change", ".makemandatory", function(e) {
makeMandatoryAlt($(this));
});

// Mandatory or Non Alt
function makeMandatoryAlt(el) {
el.each(function(i, element) {
if ($(element).prop('checked')){
//making mandatory.
$("[name='./altText']").attr('required',true);
} else {
//making not mandatory.
$("[name='./altText']").removeAttr('required');
$("[name='./altText']").removeAttr('aria-invalid');
$("[name='./altText']").removeAttr('aria-required');
$("[name='./altText']").removeAttr('invalid');
}
})
}

})(document,Granite.$,Coral);

关于xml - 带有 bool 表达式的 AEM XML 必需属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62261048/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com