2012-04-24 75 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