最近开始尝试使用jquery mobile 1.3,有一个功能模块是:滚动条到达底部时ajax异步加载下十条数据,后台php返回json数组,js处理json数组并clone页面原有ul li的最后一条,在这基础上修改之后append到ul上。
问题是append上去的没有样式,需要对ul进行refresh(不知道是为啥,看网上有人说clone的会自动加有样式,使用<li>标签临时创建才需要refresh,可我clone的还是需要refresh),我在append完之后使用$("ul").listview('refresh');语句,结果报错:Uncaught cannot call methods on listview prior to initialization; attempted to call method 'refresh'。于是我把这些append函数都放在pageshow里,$("#home").live('pageshow',function(event){...});结果还是报错额!于是在网上各种搜处理方法,page(),listview()...尝试都没有效果,再后来:
$('body ul.list').append(tempAll);
$("#home").trigger("create");
$('#home ul.list').listview("refresh");
解决了!
浙公网安备 33010602011771号