Reputation: 1798
I'm developing an app for Android using Phonegap and JQuery. It works with db Sqlite.
When I add items to the listview dynamically, css styles don't work properly. I've tried to used listview('refresh') in all possible ways. Here is my code:
$("#nextDay").click(function(){
if (opDay < 6){
opDay=opDay+1;
db.transaction(queryDB,errorCB);
$('#SheduleList').html(data);
}
else {
opDay=1;
db.transaction(queryDB,errorCB);
}
$('#SheduleList').listview('refresh');
});
function querySuccess(tx,result){
//$('#SheduleList').empty();
$.each(result.rows,function(index){
var row = result.rows.item(index);
$('#SheduleList').append('<li id=li'+row['pair_id']+'><a href="#"><h3 class="ui-li-heading">'+row['pair_name']+'</h3><p class="ui-li-desc">'+row['teach_name']+", "+row['Aud_num']+", "+row['time']+'</p></a></li>');
});
$("#SheduleList").page();
$('#SheduleList').listview();
}
Thanks for help.
Upvotes: 0
Views: 212
Reputation: 1717
It cannot be done by page refresh. You have to recreate the page data by calling $("#index").trigger("pagecreate");
I explained here in detail jquery mobile page injection
Upvotes: 0
Reputation: 35572
call this for dynamically populated container after append is done.
as
$("#SheduleList").page()
Upvotes: 1