我認爲這有一個簡單的解決方案。jQuery Mobile列表視圖:初始化錯誤
我有一個列表,我想成爲一個列表視圖。東西被動態添加到它。
HTML:
<div data-role="content" data-theme="b" class="content-primary">
<div id="friends_list_view" class="content-primary" data-theme="c">
<ul data-role="listview" data-filter="true" data-theme="c">
</ul>
</div>
</div>
的jQuery:
for(i in names){
listString = '<li><a href="#">'+i+'</a></li>';
$("#friends_list_view ul").append(listString);
}
$("#friends_list_view ul").listview('refresh');
$.mobile.hidePageLoadingMsg();
$.mobile.changePage("#friends", { transition: "slide"});
我得到:
Uncaught cannot call methods on listview prior to initialization; attempted to call method 'refresh'
當我改變它只是$("#friends_list_view ul").listview();
我得到:
Uncaught TypeError: Cannot read property 'jQuery16409763167318888009' of undefined
嘗試不帶ul:$(「#friends_list_view」)。listview(); – 2012-03-09 16:17:24
@Phill做骰子:(奇怪的是,它的確切代碼,但在另一頁上不同的ID ... – JoshDG 2012-03-09 16:27:04
做骰子=沒有骰子哈哈 – JoshDG 2012-03-09 16:35:59