问题描述
我动态填充
<ul data-role="listview">
然后调用location.href =#结果里的名单,最后.listview('刷新')结果
所有这一切都从同一个页面一个Ajax请求的成功回调完成后,
then calling location.href="#Results" where the list is, and finally .listview('refresh')
All that is done in the success callback of an ajax request from the same page,
它的工作原理或多或少,但我发现了以下错误
It works more or less but I'm getting the following error
Uncaught cannot call methods on listview prior to initialization; attempted to call method 'refresh'
我想jQuery的移动没有contruct列表视图还没有,我能怎么办呢?
I guess Jquery-mobile did not contruct the listview yet, what could I do?
推荐答案
http://jquerymobile.com/demos/1.1.0/docs/api/events.html
你要勾上的pageinit事件。你不能调用此之前的任何JQM方法。
即:
http://jquerymobile.com/demos/1.1.0/docs/api/events.htmlYou have to hook on the pageinit event. You can't call any JQM methods prior to this.i.e.:
$('#Results').bind('pageinit', function() {
$('#myListview').listview('refresh');
});
这篇关于jquerymobile错误&QUOT;不能调用列表视图的方法来初始化和QUOT之前;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!