【问题标题】:jquery mobile, browser back button navigationjquery mobile,浏览器后退按钮导航
【发布时间】:2012-09-24 16:46:02
【问题描述】:

我有一个带有#p1、#p2、#p3 的多页表单。提交表单后,当我尝试单击返回浏览器按钮时,它应该转到带有空表单字段的 #p1。使用 Jquery Mobile 可以吗?

【问题讨论】:

  • 知道它正在尝试的最好方法..
  • 您可以使用History.js 启用此类导航。
  • 能否请您详细解释一下。我将 page# 附加到 URL test.com/index.html#p1 #p2 #p3 并在 #p3 上提交表单。

标签: forms jquery-mobile browser back


【解决方案1】:

我会覆盖后退按钮并检查哪个页面是活动页面,然后根据该页面执行您需要的任何房屋清洁...

我向另一个与此非常相似的问题提交了一个示例:

BackButton Handler

在我有选项、弹出窗口和主页的地方,您可能只需要 P3,当 activePage 等于 P3 时,清除您的表单并显示 P1。

    function pageinit() {
        document.addEventListener("deviceready", deviceInfo, true);
    }

    function deviceInfo() {
        document.addEventListener("backbutton", onBackButton, true);
    } 

    function onBackButton(e) {
        try{
            var activePage = $.mobile.activePage.attr('id');

            if(activePage == 'P3'){
                clearForm(); // <-- Calls your function to clear the form...
                window.location.href='index.html#P1';

            } else if(activePage == 'P1'){

                function checkButtonSelection(iValue){
                    if (iValue == 2){
                        navigator.app.exitApp();
                    }
                }

                e.preventDefault();
                navigator.notification.confirm(
                    "Are you sure you want to EXIT the program?",
                    checkButtonSelection,
                    'EXIT APP:',
                    'Cancel,OK');

            } else {
                navigator.app.backHistory();
            }
        } catch(e){ console.log('Exception: '+e,3); }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-27
    • 2013-01-13
    • 1970-01-01
    • 1970-01-01
    • 2013-03-02
    • 1970-01-01
    相关资源
    最近更新 更多