jQuery Mobile - 样式不适用于动态表单元素

时间:2013-02-22 12:09:18

标签: jquery jquery-mobile

我使用Collapsible Accordion作为动态追加的列表。每个可折叠项目都应该有一些表单元素(文本输入,文本区域和按钮),如下图所示。

enter image description here

我的问题是,当动态附加的可折叠手风琴时,没有任何样式附加到动态附加的表单元素。

我试过$(‘#PageID’).page()但没有运气。

我的代码

var projectListStr = "<div data-role='collapsible-set' data-theme='c' data-content-theme='d' id='collabsibleProjectList' data-inset='false'>";
$.each(projectList,function(index, value){
        LineOneprojectListStr = "<br/><p class='listP2'><strong>Aktivitet </strong>: "+CheckNullToEmptyString(this.ActivityName)+"</p>";
        LineOneprojectListStr +=  "<br/><p class='listP3'><strong>Händelse/Verksamhet</strong>: "+CheckNullToEmptyString(this.EventName)+"</p>";
        projectListStr += "<div data-role='collapsible' class='myset'>";
        projectListStr += "<h3>"+this.ProjectName+"<span class='ui-li-count'>"+checkNullToZero(this.Days[i].EventTimant2)+"</span>"+LineOneprojectListStr+"</h3>";
        FormStr = "<table align='center'>";
        FormStr += "<tr><th>Hours</th><th>Minutes</th></tr>";
        FormStr += "<tr><td><input type='number' name='hoursMon' id='hoursMon' value=''  /> </td><td><input type='number' name='minsMon' id='minsMon' value=''  /></td></tr>";
        FormStr += "</table>";
        FormStr += "<div data-role='fieldcontain' >";
        FormStr += "<label for='externalNotesMon'>Fakturatext</label>";
        FormStr += "<textarea name='textarea' id='externalNotesMon' style='min-height:120px'></textarea>";
        FormStr += "</div>";
        FormStr += "<div data-role='fieldcontain'>";
        FormStr += "<label for='internalNotesMon'>Intern Text</label>";
        FormStr += "<textarea name='textarea' id='internalNotesMon' style='min-height:120px'></textarea>";
        FormStr += "</div>";
        projectListStr +=FormStr;
    projectListStr +=  "</div>";
});
projectListStr +=  "</div>";
//projectListStr +="</ul>";
$('#ProjectList').html(projectListStr);
$('#home2').page();

1 个答案:

答案 0 :(得分:5)

$('#home2').trigger('create');做了神奇的事。