listview("refresh") not working from 2nd item in the list.
I've "continent.html" with two list items:
- <ul data-role="listview">
- <li><img src="A.png" class="ui-li-icon"> <a href="countries.html?c=a">Asia</a></li>
- <li><img src="E.png" class="ui-li-icon"> <a href="countries.html?c=e">Europe</a></li>
- </ul>
"countries.html" consumes JSON and populates the list:
- <div data-role="page">
- <script>
- $.getJSON("http://api.somewhere.com/countires", function(data) {
- $('#catList').empty();
- $('#catList').listview();
- $.each(data.DATA, function(index, item) {
- var url = 'cities.html?c=' + item[0];
- var title = '<li><a href="' + url + '>' + item[1] + '</a></li>';
- $('#catList').append(title);
- });
- $('#catList').listview("refresh");
- });
- </script>
-
- <div data-role="header">
- <h2>Countries</h2>
- </div>
- <ul data-role="listview" id="catList">
- </ul>
- </div>
If I click on Asia first, I see "China, Japan, ..." but Europe comes up empty (although I see the data in #catList. If I click on Europe first, I see "France, Germany, ..." but nothing in Asia. What am I doing wrong?