Here is what I am trying to do: In a phonegap android app, use jquery listview to create a UL dynamically from my static xml and show it.
To create a filterable listview, I used the code from w3schools.
Then I add elements dynamically from my XML using the following code in onload() method in HTML body:
function parseit() {
alert("parseit");
$.ajax({
type: "GET",
url: "catalog.xml",
dataType: "xml",
success: function(xml) {
$(xml).find("Book").each(function(){
var title = $(this).find('Name').text();
console.log(title);
var listItem = '<li> <a href="#">' +title + '</li>';
$("#list").append(listItem).listview('refresh');
});
}
});
}
my XML file's schema is like :
<Books>
<Book>
<Name> somename </Name>
<Price> $1.00 </Price>
<Details> asdfgh </Details>
</Book>
<Book> ..... 1500 items of this kind... </Book>
</Books>
Few issues I am facing :
Listview does not show the newly added items immediately though I am calling refresh. I saw at few place about removing div Content etc. but I am not using it ( see code from link i gave). I have to click around, after a long time, for items to show up. Jquery listview is too slow. The # of list items I am adding is 1500-ish.
Items added dont fall into sorted headers ( eg. items starting with 'A' dont go back to that section, instead a new 'A' section is created at the bottom
I chose listview of jquery since it is giving me free search functionality.