jQuery lets you manually manipulate controls like lists. For example, you can do something like this to add an item to a list:
$('#myList').append('
');
In jQuery Mobile, if you manually update lists like that, then when you are done you must force the list to refresh so that formatting and styles are applied. To do this, just use:
$('#myList').listview('refresh');
But, there is one gotcha you should be aware of. jQuery Mobile apps are usually comprised of pages, each defined with a
Uncaught cannot call methods on listview prior to initialization; attempted to call method 'refresh'
So, if you do need to update controls on a not currently displayed page, remember to load that page before triggering the refresh.
Leave a Reply