Using Granite condition to make the field read-only
Hello All - I have a use-case to make the checkbox readonly in a dialog based on sling:resourceType using granite:RenderCondition. Can someone advise on this?
Hello All - I have a use-case to make the checkbox readonly in a dialog based on sling:resourceType using granite:RenderCondition. Can someone advise on this?
As @kunal_gaba_ said granite:renderCondition is server side implementation. Only if the condition satisfies the field will be rendered on to the dialog. The name renderCondition say it all, based on condition field will be rendered. Use below listener to disable the checkbox.
(function ($, $document, Ga) {
$document.on("dialog-ready", function() {
let checkbox = $("coral-checkbox[name='./checkbox']");
if (window.location.pathname.indexOf("/content/test/") >= 0) { //your condition
checkbox[0].disabled = true;
}
});
})(jQuery, jQuery(document), Granite.author);- AG
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.