只能顯示全部和酒店的頁面,航空的那個不能加載到動態生成的數據
<!--首頁,默認為全部-->
<div data-role="page" id="index" >
<div style="overflow: hidden;" data-role="header" data-position="fixed">
<h1>首頁</h1>
<a class="ui-btn-right" href="#" data-icon="gear">Options</a>
<div data-role="navbar" style="background-color:silver;">
<ul>
<li><a href="#index">全部</a></li>
<li><a href="#hotel">酒店</a></li>
<li><a href="#airline">航空</a></li>
</ul>
</div>
</div>
<div data-role="content"><ul data-role="listview" id="all" ></ul></div>
<div style="overflow: hidden;" data-role="footer" data-position="fixed">
<div data-role="navbar">
<ul>
<li><a href="#index">首頁</a></li>
<li><a href="#">促銷</a></li>
<li><a href="#">日歷</a></li>
<li><a href="setting.html" rel="external">設置</a></li>
</ul>
</div>
</div>
</div>
<!--酒店-->
<div data-role="page" id="hotel">
<div style="overflow: hidden;" data-role="header" data-position="fixed">
<h1>酒店</h1>
<div data-role="navbar" style="background-color:silver;">
<ul>
<li><a href="#index">全部</a></li>
<li><a href="#hotel">酒店</a></li>
<li><a href="#airline">航空</a></li>
</ul>
</div>
</div>
<div data-role="content"><ul data-role="listview" id="hotel_"></ul></div>
<div style="overflow: hidden;" data-role="footer" data-position="fixed">
<div data-role="navbar">
<ul>
<li><a href="#index">首頁</a></li>
<li><a href="#">促銷</a></li>
<li><a href="#">日歷</a></li>
<li><a href="setting.html" rel="external">設置</a></li>
</ul>
</div>
</div>
</div>
<!--航空-->
<div data-role="page" id="airline">
<div style="overflow: hidden;" data-role="header" data-position="fixed">
<h1>航空</h1>
<div data-role="navbar" style="background-color:silver;">
<ul>
<li><a href="#index">全部</a></li>
<li><a href="#hotel">酒店</a></li>
<li><a href="#airline">航空</a></li>
</ul>
</div>
</div>
<div data-role="content"><ul data-role="listview" id="airline_"></ul></div>
<div style="overflow: hidden;" data-role="footer" data-position="fixed">
<div data-role="navbar">
<ul>
<li><a href="#index">首頁</a></li>
<li><a href="#">促銷</a></li>
<li><a href="#">日歷</a></li>
<li><a href="setting.html" rel="external">設置</a></li>
</ul>
</div>
</div>
</div>
$.ajax({
url: "" ,
type: 'GET',
dataType: 'XML',//here
success: function (data) {
//生成全部列表
all = $('#all');
var iHtml = '';
hotel = $('#hotel_');
var iHtml_h = '';
airline = $('#airline_');
var iHtml_a = '';
$(data).find("record").each(
function () {
pid = $(this).children("pid").text();
flag = $(this).children("flag").text();
iHtml += '<li style="list-style-type:none;"><div style="vertical-align:middle;float:left;font-size:8%"><img style="margin-bottom: -4px;width: 14%" src="css/images/[email protected]" /><span> 酒店集團</span></div>'
+ ' <div style="vertical-align:middle;float:right;font-size:8%"> <img style="margin-bottom: -4px;width:25%" src="css/images/[email protected]" />12345</div><br />'
+ '<div> <a href="#" onclick="getcard_details(' + pid + ');"><img style=" margin: 0 0 -45% 0; overflow: hidden;" id="' + pid + '" width="100%" src=' + card_img + 'aid:' + pid + '_display:1></a></div>' + '</li>';
//生成酒店列表
if (flag == 1) {
iHtml_h += '<li style="list-style-type:none;"><div style="vertical-align:middle;float:left;font-size:8%"><img style="margin-bottom: -4px;width: 14%" src="css/images/[email protected]" /><span> 酒店集團</span></div>'
+ ' <div style="vertical-align:middle;float:right;font-size:8%"> <img style="margin-bottom: -4px;width:25%" src="css/images/[email protected]" />12345</div><br />'
+ '<div> <a href="#" onclick="getcard_details(' + pid + ');"><img style=" margin: 0 0 -45% 0; overflow: hidden;" id="' + pid + '" width="100%" src=' + card_img + 'aid:' + pid + '_display:1></a></div>' + '</li>';
}
//生成航空列表
if (flag == 2) {
iHtml_a += '<li style="list-style-type:none;"><div style="vertical-align:middle;float:left;font-size:8%"><img style="margin-bottom: -4px;width: 14%" src="css/images/[email protected]" /><span> 酒店集團</span></div>'
+ ' <div style="vertical-align:middle;float:right;font-size:8%"> <img style="margin-bottom: -4px;width:25%" src="css/images/[email protected]" />12345</div><br />'
+ '<div> <a href="#" onclick="getcard_details(' + pid + ');"><img style=" margin: 0 0 -45% 0; overflow: hidden;" id="' + pid + '" width="100%" src=' + card_img + 'aid:' + pid + '_display:1></a></div>' + '</li>';
}
})
iHtml += '<a class="ui-btn" href="#">+添加更多</a>';
all.html(iHtml).listview('refresh');
iHtml_h += '<a class="ui-btn" href="#">+添加更多</a>';
hotel.html(iHtml_h).listview('refresh');
iHtml_a += '<a class="ui-btn" href="#">+添加更多</a>';
airline.html(iHtml_a).listview('refresh');
//
}
})
試用setTimeout 調用其中一個 airline.html(iHtml_a).listview('refresh'); 看下.
Uncaught Error: cannot call methods on listview prior to initialization
這名很怪異,不知道 listview 具體怎麼實現的,會不會執行過程中有些東西改變.