Multiple radio buttons are being checked in JQuery Mobile

user3294779

I'm dynamically adding radio buttons to fieldset with the following code:

$(document).on( "pageshow", function( event, data ){
            for(var i=0 ; i<events.length ; i++){
                $('#facebookGroups').append('<input type="radio" name="radio-choice-3" id="' + events[i] + '"/>' + '<label for="' + events[i] + '">' + events[i] + '</label>').trigger('create');
            }
            var center = map.getCenter();
            google.maps.event.trigger(map, "resize");
            map.setCenter(center);
        });

This is the div that's being populated:

            <div data-role='panel' id='listPanel' data-display='overlay' data-position='right'>
                    <fieldset data-role="controlgroup" data-mini="true"     id="facebookGroups">
                        <legend>Facebook Events:</legend>

                    </fieldset>

                <a href="#homepage" data-rel="close" class='panelButton'>Close panel</a>
            </div>

The data is being filled and formatted properly, but they're not acting like radio buttons should be. I am able to select any number of them at the same time. I need to only be able to select one at a time.

Does anybody know what's going on here?

ezanker

Try this:

$('#facebookGroups input').remove();
var radios = ''
for (var i = 0; i < events.length; i++) {
    radios += '<input type="radio" name="radio-choice-3" id="' + events[i] + '"/>' + '<label for="' + events[i] + '">' + events[i] + '</label>';
}
$('#facebookGroups').append(radios).enhanceWithin();

The first line removes any inputs previously added to the controlgroup.

The for loop constructs a string with all the inputs to add.

The last line appends all the inputs and then calls enhanceWithin() to initialize the checkboxradio widgets.

Here is a DEMO

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

jQuery: Radio buttons not getting checked

From Dev

Show div if multiple radio buttons checked

From Dev

Jquery - Iterate through all checked radio buttons

From Dev

Checked Radio Buttons ID using Jquery change

From Dev

How to get the radio buttons that are NOT checked (Jquery)?

From Dev

jquery mobile won't mark radio checked

From Dev

changing the Style of Radio buttons in jQuery mobile 1.4.0

From Dev

Checking and unchecking radio buttons with Jquery Mobile 1.3.2

From Dev

Checked to see if radio buttons are checked

From Dev

Radio buttons are checked simultaneously

From Dev

Multiple submit buttons in jQuery Mobile

From Dev

Multiple submit buttons in jQuery Mobile

From Dev

Show specific div based on multiple checked radio buttons

From Dev

How to clone radio buttons in jQuery with modified checked status?

From Dev

Jquery clone elements: problems retaining checked radio buttons

From Dev

Using jQuery to check if one in set of radio buttons is checked

From Dev

jQuery change event always fires on radio buttons already checked

From Dev

javascript/jquery - hide/show table row if radio buttons checked

From Dev

How to checked jquery mobile radio button set via code

From Dev

jQuery check value of multiple radio buttons

From Dev

How to check the multiple indicdual radio buttons in jQuery?

From Dev

Rails radio buttons checked with params

From Dev

Getting checked radio buttons values

From Dev

Radio Buttons not showing up as checked

From Dev

Set radio buttons group checked

From Dev

Angular radio buttons are not checked correctly

From Dev

How to determine if radio buttons are checked?

From Dev

Radio Buttons not showing up as checked

From Dev

Getting checked radio buttons values

Related Related

  1. 1

    jQuery: Radio buttons not getting checked

  2. 2

    Show div if multiple radio buttons checked

  3. 3

    Jquery - Iterate through all checked radio buttons

  4. 4

    Checked Radio Buttons ID using Jquery change

  5. 5

    How to get the radio buttons that are NOT checked (Jquery)?

  6. 6

    jquery mobile won't mark radio checked

  7. 7

    changing the Style of Radio buttons in jQuery mobile 1.4.0

  8. 8

    Checking and unchecking radio buttons with Jquery Mobile 1.3.2

  9. 9

    Checked to see if radio buttons are checked

  10. 10

    Radio buttons are checked simultaneously

  11. 11

    Multiple submit buttons in jQuery Mobile

  12. 12

    Multiple submit buttons in jQuery Mobile

  13. 13

    Show specific div based on multiple checked radio buttons

  14. 14

    How to clone radio buttons in jQuery with modified checked status?

  15. 15

    Jquery clone elements: problems retaining checked radio buttons

  16. 16

    Using jQuery to check if one in set of radio buttons is checked

  17. 17

    jQuery change event always fires on radio buttons already checked

  18. 18

    javascript/jquery - hide/show table row if radio buttons checked

  19. 19

    How to checked jquery mobile radio button set via code

  20. 20

    jQuery check value of multiple radio buttons

  21. 21

    How to check the multiple indicdual radio buttons in jQuery?

  22. 22

    Rails radio buttons checked with params

  23. 23

    Getting checked radio buttons values

  24. 24

    Radio Buttons not showing up as checked

  25. 25

    Set radio buttons group checked

  26. 26

    Angular radio buttons are not checked correctly

  27. 27

    How to determine if radio buttons are checked?

  28. 28

    Radio Buttons not showing up as checked

  29. 29

    Getting checked radio buttons values

HotTag

Archive