I have an issue with refreshing listview.
I have 2 pages within the same html file. In both pages, I have a listview generated dynamical with Ajax:
<ul data-role="listview" data-filter="true" id="nestedList">
</ul>
And in the other one:
<ul data-role="listview" data-filter="true" id="secondList">
</ul>
After loading datas, I'm doing this:
$('#nestedList').html(dynamicNestedList);
$('#secondList').html(dynamicSecondList);
$('ul#nestedList').listview("refresh");
For the first page, everything is ok. For the second page, I added a simple script which makes the refresh on the fly:
<script>
$('ul#secondList').listview("refresh");
</script>
With jQueryMobile Beta1, I could go back to the first page and everything was still ok. With jQueryMobile Beta2, when I go back to the first page, the listview is empty...
I tried to add the same "script" to refresh on the fly the first page. It does not work. When I go back to the first page, the "Loading" jQuery message is happening and never leaves..
I've heard about the "create" trigger of jQuery Mobile Beta 2, but I may not understand what it means really...
Any solution?
You need to execute this in a live()
Example:
$('#secondList_page_id').live('pageshow',function(event, ui) {
$('#secondList').html(dynamicSecondList);
$('ul#secondList').listview("refresh");
});
$('#nestedList_page_id').live('pageshow',function(event, ui) {
$('#nestedList').html(dynamicNestedList);
$('ul#nestedList').listview("refresh");
});