Skip to content
Snippets Groups Projects
Commit 56a7a110 authored by catch's avatar catch
Browse files

Issue #1057748 by sun: Fixed #states selector matching multiple checkboxes does not trigger state.

parent a3134006
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -249,9 +249,18 @@ states.Trigger.states = {
checked: {
'change': function () {
// Use prop() here as we want a boolean of the checkbox state. See
// http://api.jquery.com/prop/ for more information.
return this.prop('checked');
// prop() and attr() only takes the first element into account. To support
// selectors matching multiple checkboxes, iterate over all and return
// whether any is checked.
var checked = false;
this.each(function () {
// Use prop() here as we want a boolean of the checkbox state.
// @see http://api.jquery.com/prop/
checked = $(this).prop('checked');
// Break the each() loop if this is checked.
return !checked;
});
return checked;
}
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment