0
在初始化或刷新我的ul时出现问题 - 我在我的代码示例中使用的方法在我正在使用的另一个函数中工作,但不在此处......我必须缺少某些东西?jQuery Mobile Listview不刷新
$(data).find("#HospitalDescriptions").find('th').filter(function(){
if (this.innerHTML !== '') {
var bgcolor = $(this).css("background-color");
var txtcolor = $(this).css("color");
if (bgcolor !== ''){
$('#information').append('<div id="alertColors"><ul><li><span style="background-color:' + bgcolor + ';color:' + txtcolor + ';">' + this.innerHTML + '</span></li></ul></div>');
} else {
$('#information').append('<li>' + this.innerHTML + '</li>');
}
}
$('#information').listview('refresh'); // not working!
});
,这里是我的HTML UL是在代码中创建:#ID的
<div data-role="page" data-theme="b" id="hospitals" data-add-back-btn="true">
<div data-role="header">
<h1>HOSP-HEADER</h1>
<a class="ui-btn-right" id="infoButton" onclick="$('#locations').listview('refresh');">Refresh</a>
</div><!-- /header -->
<div data-role="content" data-theme="b" id="regions">
<div data-role="content">
<h4>Information</h4>
<ul data-role="listview" data-inset="true" id="information">
<!-- AJAX CONTENT -->
</ul>
</div>
<div data-role="collapsible">
<h4>Regions I, II, III</h4>
<ul data-role="listview" data-inset="true" id="region3">
<!-- AJAX CONTENT -->
</ul>
</div>
<div data-role="collapsible">
<h4>Region IV</h4>
<ul data-role="listview" data-inset="true" id="region4">
<!-- AJAX CONTENT -->
</ul>
</div>
<div data-role="collapsible">
<h4>Region V</h4>
<ul data-role="listview" data-inset="true" id="region5">
<!-- AJAX CONTENT -->
</ul>
</div>
</div>
严正,不.innerHTML返回一个DOM对象?如果是这样,那么难怪if查询大部分都会失败。 – reporter
如果查询不失败,结果是好的,它只是没有在jQuery Mobile中格式化并显示为标准li – BarclayVision
您应该使用'.each'而不是'.filter'来确保您的易读性和稳定性码。 '。 – Rodik