简体   繁体   中英

jquery mobile checkbox loses style

Hi i write simple app using jqm and phonegap, and i have some problem with checkbox: they are loses style after i add some code with .append() this is my code. in .html:

        <div  data-role="fieldcontain">
        <fieldset data-role="controlgroup" id="vklConf">
            <legend>Deposit:</legend>
            <input type="checkbox" name="checkbox-1a" id="checkbox-1a" class="custom" />
            <label for="checkbox-1a">first</label>
        </fieldset>
    </div>

and in .js:

function upbConfDep(){

    mydb.transaction
  (
    function(transaction)
    {
      transaction.executeSql
      (
        'SELECT `id`, `name` FROM `deposits` WHERE `userId`='+userId+' ORDER BY `name`;',
        [],
        function (transaction, results)
        {
          var depostitNumber=results.rows.length,nowRow;
          if (results.rows.length>0)
          {
            for(var i=0;i<depostitNumber;i++)
            {
              dps=results.rows.item(i);

              $('#vklConf').append('<input type="checkbox" name="ch'+dps['id']+'" id="ch'+dps['id']+'" class="custom" />');
              $('#vklConf').append('<label for="ch'+dps['id']+'">');
              $('#vklConf').append(dps['name']);
              $('#vklConf').append('</label>');
            }
          }

        },
        DBerror
      );

    }
  );
      $("#vklConf").checkboxradio('refresh');
     //or $("input[type='checkbox']").checkboxradio("refresh"); dosn`t work
}

upbConfDep();
$('#newPrize').live
(
  'pageinit',
  upbConfDep
);

using .checkboxradio("refresh") dosn`t work. Do anyone have ideas why checkbox lose style ??

Run this code after you are done appending to page

$(".ui-page").trigger( "create" );

Example: http://jsfiddle.net/codaniel/hY7TQ/1/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM