samedi 23 mai 2015

jquery dynamic listview item with checkbox not getting selected

With jquery mobile I am using a listview and if I add an item manually with a checkbox I can select and deselect it:

<ul id="invitelist" data-role="listview" data-autodividers="true" data-filter="true" data-inset="true">
    <li data-name="test">
        <input type="checkbox" name="checkbox-v-2a" id="checkbox-v-2a">
        <label for="checkbox-v-2a">One</label>
    </li>
</ul>

However if I try to add one dynamically everything is shown correctly but the checkbox is not getting checked when I click it:

$(document).on("pageshow", "#qs_six", function( event ) {
     var output = "<li data-name='contact690'><div class='ui-checkbox'><label for='contact690' class='ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-checkbox-off'>dynamic</label><input type='checkbox'name='contact690' id='contact690' data-cacheval='true'></div></li>";
     $('#invitelist').append(output).listview('refresh');
}




Aucun commentaire:

Enregistrer un commentaire