Injected li items are not formatted with CSS style [closed]

Dynamically added listview elements must have its markup enhanced with this function:

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

Working example: http://jsfiddle.net/Gajotres/LrAyE/

In case you receive this error:

cannot call methods on listview prior to initialization

Then restyle your listview with this:

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

First listview function will initialize listview and second one will restyle it. But do this ONLY if error mentioned earlier is shown.

One last thing, if you are using for loop or each loop to add numerous li element use listview(‘refresh’) only after everything has been added to the ul element.

Read more about it in my other article/answer: jQuery Mobile: Markup Enhancement of dynamically added content, search for the chapter: Enhance a single component/widget.

Leave a Comment