0
<div data-role="fieldcontain">
    <div id="listado" data-role="listview">
        <fieldset data-role="controlgroup" id="equiposHechos">

        </fieldset>
    </div>
</div>

and my javascript is

var identificador=4
$( "#recibo" ).on( "pageinit", function( event ) {      
    for(i=0;i<=identificador;i++){      
        $("#equiposHechos").append('<input type="checkbox" name="calificarEquipo'+i+' id="calificarEquipo'+i+'"/>'+'<label for="calificarEquipo'+i+'">Equipo Numero'+(i+1)+'</label>');     
    }
})

I want to add checkboxes dynamically ... but I get no styles as I do to recharge them or that they charge me as they should be when they are static

Omar
  • 32,302
  • 9
  • 69
  • 112

2 Answers2

1

If you're using jQuery Mobile 1.3.2 or below, you need first to enhance/style markup of checkbox or radio buttons using .checkboxradio() and then re-style controlgroup by calling .controlgroup("refresh").

var identificador = 4;

for (i = 0; i <= identificador; i++) {
  $('<label for="foo' + i + '">Foo' + i + '<input type="checkbox" id="foo' + i + '"/></label>').appendTo("#equiposHechos");
}

/* widgets enhancement */
$("[type=checkbox]").checkboxradio();
$("#equiposHechos").controlgroup("refresh");

Demo

Omar
  • 32,302
  • 9
  • 69
  • 112
0

You have to explicitely ask jquery mobile to restyle them:

Check this: Dynamic controlgroup and checkboxes unstyled

$("input[type='checkbox']").checkboxradio("refresh");
Community
  • 1
  • 1
ProGM
  • 6,949
  • 4
  • 33
  • 52