listview() not working jquerymobile
I'm building an app using jquery mobile, I 'm adding content into ul tag using ajax but after loading the content the listview() function is throwing js error on console and is not working.
I've tested it with jquery.mobile-1.0rc1.min.js jquery 1.5 and 1.6.
check my code:
var loaddata = function()
{
var NPage = $('#subCatView');
var pContent = NPage.find('.content');
pContent.empty();
pContent.html('<ul></ul>');
pList = pConte开发者_如何学Pythonnt.find('ul');
pList.html("<li>Test List Item</li>");
pList.listview();
$.mobile.hidePageLoadingMsg();
return;
}
HTML:
<div id="subCatView" data-role="page">
<div class="header" data-role="header" data-theme="a">
<h1></h1>
</div>
<div class="content" data-role="content"></div>
</div>
Erorr:
Error: c[0] is undefined Source File: http://localhost/jquerymobile/jquery-mobile/jquery.mobile-1.0rc1.min.js Line: 103
It is throwing error on pList.listview();, when I remove it, error remove, but obviously listview is not created.
When I use pList.listview('refresh');
I know refresh is used when we append more items.
Error: uncaught exception: cannot call methods on listview prior to initialization; attempted to call method 'refresh'
Thanks
Try giving your <ul>
an ID like:
<ul id='dataList1'></ul>
Then call:
$('#dataList1').listview('refresh');
精彩评论