2012-04-24 71 views
1

嗨,我编写简单的应用程序使用jqm和phonegap,我有一些问题与复选框:他们失去了风格后,我添加一些代码.append()这是我的代码。 以html:使用.checkboxradio( “刷新”)dosn`t工作jquery移动复选框丢失风格

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

 <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文件。 有没有人有想法为什么复选框输入样式?

+0

你是否已经与网页()尝试刷新页面? http://stackoverflow.com/questions/5663033/jquery-mobile-dynamic-checkboxes-lose-style – arthur86 2012-04-24 08:15:12

回答

3

运行这段代码完成后追加到页面后

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

例子:http://jsfiddle.net/codaniel/hY7TQ/1/

+0

每次页面加载时,我都在为div添加反射内容,但布局被破坏了。与此合作 – 2012-11-14 15:01:14