dependsOn icon indicating copy to clipboard operation
dependsOn copied to clipboard

"checked" qualifier doesn't work on radio buttons

Open srsanborn opened this issue 10 years ago • 4 comments

The "checked" qualifier doesn't work on radio buttons as documented.

srsanborn avatar Nov 18 '14 09:11 srsanborn

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.

srsanborn avatar Nov 18 '14 10:11 srsanborn

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.

dstreet avatar Nov 18 '14 14:11 dstreet

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).

dennisdupont avatar Mar 07 '15 18:03 dennisdupont

Please update documentation with this for radio buttons. Thanks to @srsanborn

$('#some-element').dependsOn({
  'input[name="radiogroup"]': { values: ['other'] }
});

lajlev avatar Nov 19 '15 10:11 lajlev