Jquery Mobile在刷新时丢失listview样式
我花了几个小时试图弄清这一点。我正在使用Jquery mobile输出事件列表 页面加载,列表视图正常运行。我可以在我的应用程序中浏览,没有任何问题,但是当我刷新页面时,许多其他人发现JM样式被删除了。我已经尝试了论坛上提供的大部分(如果不是全部的话)解决方案,这可能意味着我没有正确地实现建议,或者它们与我的代码无关 我尝试了刷新选项“$”(“#vg_list”).listview(“刷新”);”但没有效果 从jquery文档来看,这似乎只是使用append时的相对关系 我还尝试了document.ready函数的替代方法,但没有成功。 下面是我的代码。任何帮助都将不胜感激Jquery Mobile在刷新时丢失listview样式,jquery,listview,mobile,styles,refresh,Jquery,Listview,Mobile,Styles,Refresh,我花了几个小时试图弄清这一点。我正在使用Jquery mobile输出事件列表 页面加载,列表视图正常运行。我可以在我的应用程序中浏览,没有任何问题,但是当我刷新页面时,许多其他人发现JM样式被删除了。我已经尝试了论坛上提供的大部分(如果不是全部的话)解决方案,这可能意味着我没有正确地实现建议,或者它们与我的代码无关 我尝试了刷新选项“$”(“#vg_list”).listview(“刷新”);”但没有效果 从jquery文档来看,这似乎只是使用append时的相对关系 我还尝试了documen
<div id="mygatherings"
data-theme="a"
data-role="page"
data-title="View Source:mygatherings">
<!-- header: My Gatherings start -->
<div data-role="header"
data-theme="a"
data-position="fixed"
data-id="vs_header">
<h1>My Gatherings</h1>
<a href="#home"
data-icon="home"
data-iconpos="notext"
data-transition="slide"
>Home</a>
<a href="#"
data-icon="back"
data-iconpos="notext"
data-rel="back"
data-transition="slide"
>back</a>
</div><!-- My Gatherings : create end -->
<!-- Content:My Gatherings start -->
<div id="vg" data-role="listview" ></div>
$(document).ready(function(){
$.getJSON("fetch.php", function(data) {
var output='<ul data-role="listview">';
$.each(data.result,function(key,val){
output+='<li>';
output+='<h3>Event Name:' + val.name + '</h3>';
output+='<p>Location:' + val.location + '</p>';
output+='<il>Contact:'+ val.email + '</li>';
output+='</li>';
});
output+='</ul>';
$('#vg').html(output);
});
});
我的聚会
$(文档).ready(函数(){
$.getJSON(“fetch.php”,函数(数据){
变量输出=';
$.each(数据、结果、函数(键、值){
输出+='- ';
输出+='事件名称:'+val.Name+'';
输出+='位置:'+val.Location+'';
输出+='Contact:'+val.email+'
';
输出+='';
});
输出+='
';
$('#vg').html(输出);
});
});
我在头撞了好几个小时后才发现这一点。请查看下面的代码
$(document).on('pagebeforeshow', '#mygatherings', function(){
update();
});
function update(){
$.getJSON("fetch.php", function(data) {
var output='<ul data-role="listview">';
$.each(data.result,function(key,val){
output+='<li>';
output+='<h3>Event Name:' + val.name + '</h3>';
output+='<p>Location:' + val.location + '</p>';
output+='<il>Contact:'+ val.email + '</li>';
output+='</li>';
output+='</ul>';
});
$('#vg').html(output);
$("#vg").listview("refresh");
});
}
$(document).on('pagebeforeshow','#mygatherings',function(){
更新();
});
函数更新(){
$.getJSON(“fetch.php”,函数(数据){
变量输出=';
$.each(数据、结果、函数(键、值){
输出+='- ';
输出+='事件名称:'+val.Name+'';
输出+='位置:'+val.Location+'';
输出+='Contact:'+val.email+'
';
输出+='';
输出+='
';
});
$('#vg').html(输出);
$(“#vg”).listview(“刷新”);
});
}
像这样使用
$.getJSON("fetch.php", function(data) {
var output='<ul data-role="listview">';
$.each(data.result,function(key,val){
output+='<li>';
output+='<h3>Event Name:' + val.name + '</h3>';
output+='<p>Location:' + val.location + '</p>';
output+='<il>Contact:'+ val.email + '</li>';
output+='</li>';
});
output+='</ul>';
$('#vg').html(output);
}).done(function(){
$("#listviewid").listview().listview("refresh");
});
$.getJSON(“fetch.php”,函数(数据){
变量输出=';
$.each(数据、结果、函数(键、值){
输出+='- ';
输出+='事件名称:'+val.Name+'';
输出+='位置:'+val.Location+'';
输出+='Contact:'+val.email+'
';
输出+='';
});
输出+='
';
$('#vg').html(输出);
}).done(函数(){
$(“#listviewid”).listview().listview(“刷新”);
});