Multi page template in jquery mobile

坚强是说给别人听的谎言 提交于 2020-01-06 08:12:14

问题


I create my pages using multi page template, I read that only start page(e.g index.aspx) still remain in Dom in each pages when loading. but now in my other page(e.g child.aspx) which is a child of page parent.aspx, I can see dom element of parent.aspx page. the breadcrumb is as follow: Index--->parent--->child, maybe I should see only the index dom content not parent. this make me wonder why the page is like this and how I can handle it.Thanks

update:

I just want to reload every page on each showing, I mean clearing the DOM completely and loading content from the beginning. Like when you push ctrl+f5 and load page without cache. Is this possible in JQM?

Index.aspx:

    <form id="form1" runat="server" dir="rtl">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode = "Conditional">
            <ContentTemplate>
        <asp:ScriptManager ID="ScriptManager" runat="server"></asp:ScriptManager>
        <uc2:MblMyMessageBox ID="MblMyMessageBoxInfo" runat="server" ShowCloseButton="true" /> 
    <div data-role="page" id="home"> 
        <div data-role="header">
            <h1>header</h1>
        </div>
        <div data-role="content">   
            <ul data-role="listview" data-inset="true" data-filter="false">
                <li data-icon="false"><a href="AccountStatus.aspx">AccountStatus</a></li>
                <li data-icon="false"><a href="ConfirmPayment.aspx">ConfirmPayment</a></li>
            </ul>   
        </div>
    </div>
            </ContentTemplate>
    </asp:UpdatePanel>
</form>

AccountStatus.aspx:

 <div data-role="page" id="accountStatus">
    <div data-role="header">
        <h1>Header</h1>
    </div><!-- /header -->
    <div data-role="content">   
        <ul data-role="listview" data-inset="true" data-filter="false">
            <li data-icon="false"><a href="BalancePage.aspx" data-prefetch="true">balance</a></li>
            <li data-icon="false"><a href="InvoicePage.aspx">invoice</a></li>
        </ul>           
    </div><!-- /content -->
    <div data-role="footer">
        <p><a href="Index.aspx">back</a></p>
    </div><!-- /footer -->
 </div><!-- /page -->   

removing content of index from accountStatus page dom element is my purpose.


回答1:


All pages that the user has navigated to will be added to the dom. See the documentation. However jQM also has a mechanism to keep the DOM from getting to big and slowing down the browser. It may or may not remove old elements from the DOM. I would advice you not to trust on DOM elements getting removed automatically. If you really want to remove the page you are navigating away from, you can bind for example the following:

$(document).one("pageshow",function(){
     $(document).one("pagehide",function(){
          $("#pageId").remove();
     });
});

Where pageId is the id you give to the <div data-role="page" id="pageId">.

Edit for the updated question: To reload the whole page when following links:

Links that point to other domains or that have rel="external", data-ajax="false" or target attributes will not be loaded with Ajax. Instead, these links will cause a full page refresh with no animated transition.

Source: jQuery Mobile Docs

Or you can change it with the following global variable:

$.mobile.ajaxEnabled = false;


来源:https://stackoverflow.com/questions/12651400/multi-page-template-in-jquery-mobile

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