jQuery Mobile: How to refresh page with dynamic DOM manipulation?

自古美人都是妖i 提交于 2019-12-10 22:45:36

问题


I created a page with jQuery Mobile, and tried to add content dynamically:

    $(function () {

        $("#deviceTarget").sortable({
            revert: true
        });

        $("body > div[data-role='page']").append($("<div data-role='header' data-theme='a' data-position='fixed'><h1>Header</h1></div>"));
        $("body > div[data-role='page']").append($("<div data-role='footer' data-theme='a' data-position='fixed'><h1>Footer</h1></div>"));
        $.mobile.activePage.trigger("create");

    });

    $(document).bind('mobileinit',function(){
        $.mobile.defaultPageTransition = 'none';
        $.mobile.selectmenu.prototype.options.nativeMenu = false;
      });

    function refreshPage() {
        $.mobile.activePage.trigger("create");
    }

But I got the result (image).

I want to get the result (image).

How can I do?

Thanks.


回答1:


all you need to do is to refresh the page

not sure about this code:

    $.mobile.activePage.trigger("refresh");

but it should work. Otherwise take a look at this jquerymobile.com article.



来源:https://stackoverflow.com/questions/9581653/jquery-mobile-how-to-refresh-page-with-dynamic-dom-manipulation

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