所以问题是,第一次,页面没有加载css.but我选择后再次转到该页面,css被加载。
这是我的代码......
的script.js
$('#find_gas').live('pageshow',function(){
$('#cat_gas').bind('click',function(e){
var id_subkategori, id_kategori;
id_kategori=3;
switch ($(e.target).children().html()) {
case 'All':
//alert('all');
id_sub_kategori='';
break;
case 'Shell':
id_sub_kategori=8;
break;
case 'Pertamina':
id_sub_kategori=9;
break;
}
navigator.geolocation.getCurrentPosition(function(position){
//alert(id_sub_kategori);
var latitude=position.coords.latitude;
var longtitude=position.coords.longitude;
var postdata = {'id_sub_kategori':id_sub_kategori,'id_kategori':id_kategori,'latitude':latitude,'longtitude':longtitude};
var output = $('#hasilhotel');
var link = 'http://*my_ip_address*/TA/php/find.php';
//alert ('masuk');
$.ajax({
type: 'GET',
url: link,
dataType: 'jsonp',
data: postdata,
jsonp: 'jsoncallback',
timeout: 5000,
success: function(data){
// $('#hasilhotel').trigger("create");
var str='<div data-role="header" class="ui-header ui-bar-a" role="banner"><a href="history.go(-1)" data-role="button" data-rel="back" data-icon="back" class="ui-btn-left ui-btn ui-shadow ui-btn-corner-all ui-btn-icon-left ui-btn-up-a" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-theme="a"><span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text">Back</span><span class="ui-icon ui-icon-back ui-icon-shadow"> </span></span></a><a href="#home" data-role="button" data-icon="home" class="ui-btn-right ui-btn ui-shadow ui-btn-corner-all ui-btn-icon-left ui-btn-up-a" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-theme="a"><span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text">Home</span><span class="ui-icon ui-icon-home ui-icon-shadow"> </span></span></a><h3 class="ui-title" role="heading" aria-level="1">GAS STATION</h3></div><div data-role="content" class="ui-content" role="main"><ul data-role="listview" data-icon="arrow-r" class="ui-listview">';
var count=0;
$.each(data, function(i,item){
str = str +'<li class="ui-li ui-li-static ui-body-c"><a href="#"><h3 class="ui-li-heading"><input type="hidden" value="'+item["id_place"]+'" id="id_place" >'+item["nama_place"]+'   : ('+Math.round(item["distance"]*100)/100+' Km)</h3></a></li>';
count++;
});
if(count==0)
{
str = str +'<li class="ui-li ui-li-static ui-body-c"><h3 class="ui-li-heading">Tidak ada Tempat Terdekat</h3></li>';
}
str=str+'</ul></div>';
output.html(str);
//output.listview('refresh');
$.mobile.path.set('hasilhotel');
$('#hasilhotel').trigger("create");
//hasil_hotel();
//console.log(data);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.responseText);
alert(thrownError);
}
});
});
});
});
当我将触发器移动到顶部时,css被加载,但是当我第二次和第二次返回该页面时,css不会再次加载....