JQM (jQueryMobile) Push last page out of DOM on changePage()

匿名 (未验证) 提交于 2019-12-03 02:30:02

问题:

I notice that the page that I was just viewing is still in the DOM. Is there a way to remove the last page viewed after I transition to the new page using changePage()?

I have disabled all the back navigation as I don't want the use to go back to the last page when transitioning to the new page(s).

Any suggestions?

Flow of the site:

  • main page-> fill out info->submit on changePage()
  • next page-> fill out more info-> submit on changePage()
  • etc...

Once the page has been submitted I don't need it anymore

UPDATE:

Here is the first page:

<div data-role="page"       id="first_page"       data-theme="z"       data-backbtn="false"       data-url="first_page"       class="ui-page       ui-body-z"> 

It appends something to this when adding a new page:

<div data-role="page"       id="next_page"       name="next_page"       data-theme="z"       data-title="next_page"       data-url="getNextPage.php?page=next_page"       class="ui-page       ui-body-z"> 

Calling the live() like this:

// pageName[index] = next_page $('#'+pageName[index]).live('pagecreate',function(event, ui){        $(ui.prevPage).remove(); 

using changePage() like this:

$.mobile.changePage('getNextPage.php?page='+pageName[index],'slide',false,false); 

回答1:

Not exactly knowing your markup I am guessing you are triggering changePage() manually. If that is the case, you could wire up one of the events listed here.

pageshow
Triggered on the page being shown, after its transition completes.

$('div').live('pageshow',function(event, ui){   $(ui.prevPage).remove(); }); 

Example on jsfiddle.



回答2:

I'm not sure if it's related to your issue - but there was a JQM fix that went in yesterday related to errors when attempting to delete DOM elements: https://github.com/jquery/jquery-mobile/commit/d4c7b5da66641a3fd081a834ca3d12a5518d499b



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