jQuery mobile error "cannot call methods on listview prior to initialization"

you should check if it is already initialized or not, refresh the list in case it is initialized otherwise trigger create as per the following :

if ( $('#myListview').hasClass('ui-listview')) {
    $('#myListview').listview('refresh');
     } 
else {
    $('#myListview').trigger('create');
     }

http://jquerymobile.com/demos/1.1.0/docs/api/events.html You have to hook on the pageinit event. You can't call any JQM methods prior to this. i.e.:

$('#Results').bind('pageinit', function() {
  $('#myListview').listview('refresh');
});

I had the same error. I solved it by adding ":visible" to my query, so it will only run if the list is visible.

So your code will look something like this:

$('#myListview:visible').listview('refresh');

Worked fine for me!


Just call the listview method without any parameter first:

$('#myListview').listview().listview('refresh');

Solution taken from http://www.gajotres.net/uncaught-error-cannot-call-methods-on-prior-to-initialization-attempted-to-call-method-refresh/