I have some checkboxes in a button set and I want to use Jquery to check one of the checkboxes.
It works, however, the visual representation of the checkbox does not update. ie, after executing $('#chk').attr('checked',true);
the checked value is true, but the checkbox apears unchecked.
Demoed here: /
Thanks!
I have some checkboxes in a button set and I want to use Jquery to check one of the checkboxes.
It works, however, the visual representation of the checkbox does not update. ie, after executing $('#chk').attr('checked',true);
the checked value is true, but the checkbox apears unchecked.
Demoed here: http://jsfiddle/kralco626/jzVjT/1/
Thanks!
Share Improve this question edited Dec 6, 2010 at 14:20 kralco626 asked Dec 6, 2010 at 14:14 kralco626kralco626 8,64441 gold badges115 silver badges171 bronze badges 3- 1 Note: when you click the button in the jsfiddle example, the checkbox is being checked. You can tell because when you click the checkbox after clicking the button the checkbox still appears in the "unchecked" state. – kralco626 Commented Dec 6, 2010 at 14:16
- Nick Craver's answer should work. As an aside, I'd say if what you really want is a buttonset, then you probably want to have your original source be a group of radio buttons, not checkboxes. Usually a buttonset provides a group of mutually exclusive options, whereas checkboxes each toggle an individual property on or off (those turn into toggle buttons when you call .button() on them directly). – RwwL Commented Dec 6, 2010 at 14:20
- I want checkbox functionality, not radio button functionality. A Jquery buttonset will either be a checkbox type set or a radio button type set based on whether it contains inputs of type checkbox, or radio. – kralco626 Commented Dec 6, 2010 at 14:20
2 Answers
Reset to default 16You need to call the refresh
method on the buttonset to update the visual state after programmatic changes to the checked
state, like this:
$("#test").buttonset("refresh");
You can test it out here.
Try
'true'
rather than
true
Attributes are always string values.
Edit:
Never mind. No clue on buttonset functionality but things aren't behaving normally. Check the documentation for the API.