Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refactor cascadeForm for JQ3 #240

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
Loading