admin管理员组文章数量:1025259
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
2 Answers
Reset to default 6You 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});
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
2 Answers
Reset to default 6You 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});
本文标签: javascriptDelete first page in JQuery Mobile historyStack Overflow
版权声明:本文标题:javascript - Delete first page in JQuery Mobile history - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745618576a2159438.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论