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
......@@ -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;
}
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment