A few problems:
The
button
widget works by responding to click events on the radio button's label. This means that theclick
event you are listening to on the radio buttons themselves won't get fired, since you actually aren't clicking the radio buttons themselves, but theirlabel
s. You can work around this by using thechange
event.You need to call
.buttonset('refresh')
after manually updating the checked state of a radio button.Just setting the
checked
attribute on one radio button in a group is enough to make the rest become unchecked automatically. You shouldn't need to set thechecked
property on each one.You should put your event handlers inside the
document.ready
handler as well. You can also just use one instead of two.
With all of those things in mind, here are the changes I would make:
$(function () {
$("#sort-radio").buttonset();
$("#alphabet-radio").buttonset().find('label').css('width', '19.4%');
document.getElementById("byState").addEventListener("change", function () {
document.getElementById("A-C").checked = true;
$("#alphabet-radio").buttonset("refresh");
}, false);
document.getElementById("byCity").addEventListener("change", function () {
document.getElementById("A-C").checked = true;
$("#alphabet-radio").buttonset("refresh");
}, false);
});
Example: http://jsfiddle.net/Fzq8L/2/