etolstoy
etolstoy

Reputation: 1798

listview('refresh') don't work

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

Answers (2)

Akilan
Akilan

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

Rab
Rab

Reputation: 35572

call this for dynamically populated container after append is done.

as

$("#SheduleList").page()

Upvotes: 1

Related Questions