jQuery Mobile的,删除previous页 [英] Jquery mobile, remove previous page

查看:120
本文介绍了jQuery Mobile的,删除previous页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery移动与PhoneGap的。我的应用程序有两页:登录页面和列表页面。当用户登录成功后,用户会转到列表页面。后来,当他们preSS对自己的手机(安卓)返回按钮,他们将回到登录页面。我不希望这样的行为。我要的是退出应用程序。

I'm using jquery mobile with phonegap. My app has two pages: login page and list page. When login successfully, the user will go to the list page. Afterwards, when they press the back button on their phone (android), they will go back to the login page. I don't want behavior like this. What I want is to exit the app.

推荐答案

我在这个问题回答说:<一href="http://stackoverflow.com/questions/11069421/page-hash-and-backbutton-issue-phonegapjquery">page哈希和后退按钮问题的PhoneGap + jQuery的

As I answered in this question: page hash and backbutton issue phonegap+Jquery

您可以更改页面,而不让他们在浏览器历史记录,像这样:

You can change pages without keeping them in browser history like so:

$.mobile.changePage('#page', {reverse: false, changeHash: false});

不幸的是,我并没有停留在浏览器历史记录管理,以prevent初始页面,所以我用了一个解决方法:

Unfortunately, I didn't manage to prevent the initial page from staying in browser history, so I used a workaround:

页面布局:

<body>    
    <!-- page_1 before page_loading in source -->
    <div data-role="page" id="page_1">
    </div>
    <!-- page_loading will be shown first -->
    <div data-role="page" id="page_loading">
        <div data-role="content">
            <h1 >
                <b>welcome</b>
            </h1>
        </div>
    </div>
    <div data-role="page" id="page_2">
    </div>    
</body>

jQuery的:

jQuery:

function onBodyLoad()
{   
    //go to page_loading before deviceready without keeping it in browser history
    $.mobile.changePage('#page_loading', {reverse: false, changeHash: false});
    document.addEventListener("deviceready", onDeviceReady, false);
}

function onDeviceReady()
{   
    //your initialization code here...

    //now go to page_1 without keeping it in browser history since the actual first page was #page_1 already       
    $.mobile.changePage('#page_1', {reverse: false, changeHash: false});

    //your code here...
}

这应该满足您的需求,只是尝试一下。 #page_loading将是你的登录页面,page_1您的列表页...

This should fit your needs, just try it out. "#page_loading" would be your login page, "page_1" your list page...

这篇关于jQuery Mobile的,删除previous页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆