Sergio
Sergio

Reputation: 329

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 ??

Upvotes: 1

Views: 1547

Answers (1)

codaniel
codaniel

Reputation: 5253

Run this code after you are done appending to page

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

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

Upvotes: 3

Related Questions