dependsOn
dependsOn copied to clipboard
"checked" qualifier doesn't work on radio buttons
The "checked" qualifier doesn't work on radio buttons as documented.
For what it's worth, my current workaround has been to use the values qualifier on a set of radio buttons, like so:
$('#text_field').dependsOn( {'input[name="radio_button_set"]': {values: ['one']}}, {hide: false} );
...but it would be nice to simplify this to depend on the checked state of a specified element vs value-based dependency.
Thanks for pointing that out. The documentation is incorrect. The checked
qualifier is meant to only work on checkboxes. I will consider allowing this qualifier to be used for radio buttons, but since a radio group is meant to represent multiple states of a single property, the values
qualifier best fits this need.
This works if you want a specific value, but not if you want to check against unchecked. Rather than have to repeat all possible values (a maintenance headache and not very DRY), I should be able to use {not: [undefined]} (although I'm not sure jquery will normalize all browsers to undefined - better to check for null or empty string also).
Please update documentation with this for radio buttons. Thanks to @srsanborn
$('#some-element').dependsOn({
'input[name="radiogroup"]': { values: ['other'] }
});