Hide show 2 different feilds on the basis of 2 radio buttons in same tab in page properties
I have a requirement for Hide show 2 different feilds on the basis of 2 radio buttons in same tab in page properties and i also want to persist either data on the basis of authoring. How can i acheive this in aem. Below one is not working.
(function (document, $, Coral) {
"use strict";
$(document).on("foundation-contentloaded", function () {
var radioGroup = $(".cq-dialog-radio-showhide");
var target = radioGroup.attr("data-cq-dialog-radio-showhide-target");
if (!target) return;
function toggle() {
var value = $("input[type=radio]:checked").val();
console.log("Selected value:", value);
$(target).each(function () {
var $target = $(this);
var showValue = $target.attr("data-showhidetargetvalue");
if (value === showValue) {
$target.removeClass("hide").show();
} else {
$target.addClass("hide").hide();
// 🔥 also hide inner field wrappers
$target.find(".coral-Form-fieldwrapper").hide();
}
});
}
setTimeout(toggle, 200);
$(document).on("change", "input[type=radio]", function () {
setTimeout(toggle, 50);
});
});
})(document, Granite.$, Coral);
