jquery mobile does not render list after jquery template was inserted

ぐ巨炮叔叔 提交于 2019-12-21 21:59:37

问题


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

    回答1:


    jQM Docs:

    • http://jquerymobile.com/demos/1.0/docs/lists/docs-lists.html

    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.



    来源:https://stackoverflow.com/questions/8743931/jquery-mobile-does-not-render-list-after-jquery-template-was-inserted

  • 易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
    该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!