0

I'm trying to inject radio buttons into my jQuery-Mobile page and it seems to go well minus one detail. I can only ever select the radio buttons once. Once they have been checked, no amount of clicking will uncheck them. The code for injection is below, any ideas on what I'm doing wrong?

function load_states() {
    for(var i in level1_states) {
       var str = " ";
       str += "<label for=\" "+i+" \">"+i+"</label>";
       str += "<input type=\"radio\" name=\" "+i+" \" id=\" "+i+" \" value=\""+i+" \" />";

       $(str).appendTo("#level1");
    }
    $("input[type='radio']").prop("type", "radio").checkboxradio();
    $("#level1").controlgroup("create");
}
4

1 に答える 1

0

The problem here was that I was setting each radio button's name attribute to have a unique value. I hadn't known that in order for standard html radio buttons to operate correctly, they need to have a common name attribute, as per description here:

http://forum.jquery.com/topic/radio-buttons-not-working-as-expected

于 2012-09-24T16:22:29.810 に答える