javascript - Delete first page in JQuery Mobile history - Stack Overflow

I'm doing a Cordova App usin jQuery Mobile. My first page is a 'Loading' page, where I d

I'm doing a Cordova App usin jQuery Mobile. My first page is a 'Loading' page, where I download all needed data for App. After that, App goes to menu. I want to delete that loading page from history.

My problem is that as far as I know, disable insertion of pages inside history can be done only when pages are loaded using $.mobile.changePage (changehash=false). I'm using jqueryMovile-1.4.2 & cordova 3.4.0.

Does anybody know a approach to this problem?

I'm doing a Cordova App usin jQuery Mobile. My first page is a 'Loading' page, where I download all needed data for App. After that, App goes to menu. I want to delete that loading page from history.

My problem is that as far as I know, disable insertion of pages inside history can be done only when pages are loaded using $.mobile.changePage (changehash=false). I'm using jqueryMovile-1.4.2 & cordova 3.4.0.

Does anybody know a approach to this problem?

Share Improve this question edited Apr 9, 2014 at 8:56 pozuelog asked Apr 9, 2014 at 8:38 pozuelogpozuelog 1,31415 silver badges27 bronze badges 2
  • which version are you using? – Omar Commented Apr 9, 2014 at 8:50
  • I'm using jqueryMovile-1.4.2 & cordova 3.4.0. – pozuelog Commented Apr 9, 2014 at 8:55
Add a ment  | 

2 Answers 2

Reset to default 6

You need to do two things, remove page div from DOM as well as from navigation history. This can be done by listening to pagecontainershow and read ui.prevPage object, as it holds data of previous page (not current active one).

When pagecontainershow fires, check the type of returned ui.prevPage, it shouldn't be undefined. If it is defined (means you have moved from first page in DOM to any other page) at this stage, .remove() from DOM and from $.mobile.navigate.history.stack.

$.mobile.navigate.history.stack.splice(0,1); this will remove first record in urlHistory stack.

$(document).on("pagecontainershow", function (e, ui) {
  if (typeof ui.prevPage[0] !== "undefined" && ui.prevPage[0].id == "pageID") {
    $.mobile.navigate.history.stack.splice(0,1);
    $(ui.prevPage).remove();
  }
});

Demo

What's your issue with changehash=false?

You should just use it when transitionning from the loading page to the menu.

This looks much like what I do in my own app, except in my case history is handled by Backbone.

$.mobile.changePage($("#menuPage"), {changeHash: false});

And starting with jquery 1.4, you should no more use $.mobile.changePage but instead :

$("body").pagecontainer("change",$("#menuPage"), {changeHash: false});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745618578a4636383.html

相关推荐

  • javascript - Delete first page in JQuery Mobile history - Stack Overflow

    I'm doing a Cordova App usin jQuery Mobile. My first page is a 'Loading' page, where I d

    9小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信