I am trying to manually set a radio button to checked, but there is a problem. The code works just fine:
$('#'+align+'Text').attr("checked","checked");
But when I put jQuery UI into practice and make the radios a buttonset, everything breaks. Again, everything works fine until I put in the .buttonset(), then they look much better than normal radios, but the setting above does not work at all.
EMPHASIS ON THE FOLLOWING:
Has anyone been able to manually set a radio button while .buttonset() is active on those radios?
All you need to do is call the "refresh" operation on the button widget after setting the "checked" attribute.
$('#'+align+'Text').attr("checked","checked").button('refresh');
Here's the jsfiddle.
Note that setting the "checked" property can (and, some would say, should) be set with the .prop()
function:
$('#' + align + 'Text').prop('checked', true).button('refresh');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With