Skip to content

Commit

Permalink
fix: refactor cascadeForm for JQ3 (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
fibble authored Sep 6, 2024
1 parent 7e0ad37 commit fc34c80
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/cdn/assets/_js/components/cascadeForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ OLCS.cascadeForm = (function(document, $, undefined) {
$.each(elems, function(i, elem) {
elem = $(elem);
if (elem.is(":checked")) {
elem.removeAttr("checked");
elem.prop("checked", false);
}
});
// ensure the change notification cascades down the line
Expand Down Expand Up @@ -100,9 +100,9 @@ OLCS.cascadeForm = (function(document, $, undefined) {
}
OLCS.logger.verbose(
group + " > " + selector +
", should show? (" + show + "), is visible? (" +
elem.is(":visible") + "), action: (" +
action + ")",
", should show? (" + show + "), is visible? (" +
elem.is(":visible") + "), action: (" +
action + ")",
"cascadeForm"
);

Expand Down Expand Up @@ -161,9 +161,9 @@ OLCS.cascadeForm = (function(document, $, undefined) {
// assume a name=value pair specifies a radio button with a given value
parts = selector.split("=");
return OLCS.formHelper.findInput(group, parts[0])
.filter("[value=" + parts[1] + "]")
// radios are always wrapped inside a label
.parents("label:last");
.filter("[value=" + parts[1] + "]")
// radios are always wrapped inside a label
.parents("label:last");
}

// otherwise assume a straight input name which we assume is inside a field container
Expand Down Expand Up @@ -199,6 +199,8 @@ OLCS.cascadeForm = (function(document, $, undefined) {
$(document).on("change", formSelector, checkForm);

OLCS.eventEmitter.on("render", checkForm);

checkForm();
};

}(document, window.jQuery));
}(document, window.jQuery));

0 comments on commit fc34c80

Please sign in to comment.