1

嗨,我使用 jqm 和 phonegap 编写了简单的应用程序,但我的复选框有一些问题:在我使用 .append() 添加一些代码后,它们失去了风格,这是我的代码。在 .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>

在 .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
);

使用 .checkboxradio("refresh") 不起作用。有谁知道为什么复选框会失去风格?

4

1 回答 1

3

Run this code after you are done appending to page

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

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

于 2012-04-24T08:44:56.100 回答