【发布时间】:2011-08-01 14:34:51
【问题描述】:
这是对我正在做的事情的模拟:
function loadPage(pn) {
$('#'+pn).live('pagecreate',function(event, ui){
$('#'+pn+'-submit').click( function() {
$.mobile.changePage({
url: 'page.php?parm=value',
type: 'post',
data: $('form#'+pn+'_form')
},'slide',false,false);
loadAjaxPages(pn);
});
});
function loadAjaxPages(page) {
// this returns the page I want, all is working
$.ajax({
url: 'page.php?parm=value',
type: 'POST',
error : function (){ document.title='error'; },
success: function (data) {
$('#display_'+page+'_page').html(data); // removed .page(), causing page to transition, but if I use .page() I can see the desired listview
}
});
}
如果我添加 .page()(过去可以使用,但我将它放在页面函数之外,更改了加载页面的逻辑以节省加载时间),则在 ajax 调用返回中,使页面转换到下一页,但我可以看到列表视图的样式是我想要的:
$('#display_'+page+'_page').html(data).page();
删除 .page() 修复了转换错误,但现在页面没有样式。我试过listview('refresh') 甚至listview('refresh',true) 但没有运气。
关于如何让列表视图刷新有什么想法吗?
解决方案:
$.ajax({
url: 'page.php?parm=value',
type: 'POST',
error : function (){ document.title='error'; },
success: function (data) {
$('#display_'+page+'_page').html(data);
$("div#name ul").listview(); // add div wrapper w/ name attr to use the refresh
}
});
【问题讨论】:
-
收到您的消息要检查一下,但我知道您现在有了解决方案。 :)
-
如果有人需要更多信息,这是我的问题stackoverflow.com/questions/5589358。
标签: ajax listview jquery jquery-mobile