Stewie Griffin
Stewie Griffin

Reputation: 9337

jquery mobile does not render list after jquery template was inserted

I am adding

  • tags using jquery templates to jquery Mobile website. It adds li tags, however it does not style in the standard jqueryMobile style. I can see it visually and by inspecting DOM: jquery mobile adds classes and convert to div and span classes, where in my case I see plane ul and li tags without any jquery mobile classes. I have a version, that it loads first Jquery Mobile, and then injects jquery template and Mobile does not refresh that list and doesnt style it. Is there a way to fix it and display standard jMobile list after jquery template was injected? Thanks

    Upvotes: 2

    Views: 1314

  • Answers (1)

    Phill Pafford
    Phill Pafford

    Reputation: 85388

    jQM Docs:

    Updating lists If you add items to a listview, you'll need to call the refresh() method on it to update the styles and create any nested lists that are added. For example:

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

    Note that the refresh() method only affects new nodes appended to a list. This is done for performance reasons. Any list items already enhanced will be ignored by the refresh process. This means that if you change the contents or attributes on an already enhanced list item, these won't be reflected. If you want a list item to be updated, replace it with fresh markup before calling refresh.

    Upvotes: 6

    Related Questions