css - jQuery Mobile doesn't apply style on dynamic checkboxes and can't clicked -
i'm trying refresh number of checkboxes has been appended in fieldset tag when clicked @ menu tab footer. 1st tab visit okay after that, checkboxes can't checked anymore. have been modified code several times doesn't work. can checked without style applied. can't checked have style applied.
i have tried .controlgroup('refresh');
, .checkboxradio("refresh");
none of them working. have @ of similar questions they're not helping me solve problem. may put code in wrong place?
for .checkboxradio("refresh");
console log error. cannot call methods on checkboxradio prior initialization; attempted call method 'refresh'
this original html , js
<div data-role="content" data-theme="a"> <div id='delete_wrapper'> <a href="#" data-role="button" id='deletebutton'>delete</a> <a href="#" data-role="button" id='deleteallbutton'>delete all</a> </div> <fieldset data-role="controlgroup" id='checkboxes_wrapper2'> </fieldset> </div>
and js
runfirstdelete = true; $('.delete_tab').click(function(){ $("#checkboxes_wrapper2").children().remove(); var dataindex; var dataname; for(var in localstorage) { dataindex = json.parse(localstorage[i]).index; dataname = json.parse(localstorage[i]).name; if(runfirstdelete){ // 1st time visit, it's working okay. $("#checkboxes_wrapper2").append('<input type="checkbox" name="'+dataindex+'" id="checkbox'+dataindex+'" value="'+dataindex+'"/><label for="checkbox'+dataindex+'">'+dataname+'</label>'); } else{ //if not, trying insert embedded style in element $('#checkboxes_wrapper2').append('<div class="ui-checkbox"><input type="checkbox" value="'+dataindex+'" name="'+dataindex+'" id="checkbox'+dataindex+'"><label for="checkbox'+dataindex+'" data-corners="true" data-shadow="false" data-iconshadow="true" data-wrapperels="span" data-icon="checkbox-off" data-theme="a" data-mini="false" class="ui-checkbox-off ui-btn ui-btn-up-a ui-btn-corner-all ui-fullsize ui-btn-icon-left ui-btn-up-a"><span class="ui-btn-inner"><span class="ui-btn-text">'+dataname+'</span><span class="ui-icon ui-icon-checkbox-off ui-icon-shadow"> </span></span></label></div>'); } } runfirstdelete = false; //then indicate it's not 1st click on tab });
since adding new elements, there no jquery mobile widgets augment them, trying call refresh()
method indeed fail.
a simple way of telling jquery mobile "catch up" new markup trigger create
event on container element:
$("#checkboxes_wrapper2").trigger("create");
Comments
Post a Comment