在android 2.3.6上使用changePage的不寻常行为

时间:2014-02-08 03:43:15

标签: android jquery-mobile cordova

我正在使用jquery mobile和build.phonegap.com构建一个phonegap应用程序

我有一个事件在启动过程完成后将页面更改为登录屏幕。

这样可以正常工作,但除非安装了调试器,否则它无法在我的andriod设备上运行,在这种情况下它可以正常工作。

我的代码是

$.mobile.changePage("login.html");

我把它放在mobileinit,pageshow中,现在放在document.ready函数上,但它不会改变行为。

我已经检查过$ .mobile是否是一个功能,它已经尝试了所有内容并且似乎无法弄清楚为什么会这样,任何反馈都会非常感激

1 个答案:

答案 0 :(得分:0)

我成功地解决了这个问题。

这与我的手机真的很老很慢有关,所以有些东西在老/慢的andriod版本上有些混乱。

为了防止这是一个问题,我想通过这种方式解决了这个问题并在手机间隙启动了我的jquery移动应用,即使手机很慢。

$(document).bind('mobileinit', function () {
    setTimeout(function () {
        var html = $(".loading-status-text").html();
        /* The html has Please Wait in the dom so we know it han't been touched by jQuery */
        if (html == 'Please Wait') {
            window.location.href = 'index.html';
        }
    }, 10000);

    $(document).on("pageshow", function (e) {
        var pageId = $.mobile.activePage.attr('id').toString();
        if (pageId == 'loadingScreen') {
            /* This wouldn't fire at first */
            $(".loading-status-text").html("Welcome to Appname");
            $.mobile.changePage("login.html");
        }
    });
});