Android jQuery Mobile无法使用PhoneGap

Android jQuery Mobile无法使用PhoneGap,android,html,jquery-mobile,cordova,Android,Html,Jquery Mobile,Cordova,我正在开发一个应用程序,正在使用。上次我在做这个项目时,它看起来很棒,但现在jQuery Mobile停止了工作。发生什么事了 这是我的密码: <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" /> <scr

我正在开发一个应用程序,正在使用。上次我在做这个项目时,它看起来很棒,但现在jQuery Mobile停止了工作。发生什么事了

这是我的密码:

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
        <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
    </head>

    <body>
        <div id="page" data-role="page" data-theme="b">
            <div data-role="content">
            <h2>Login To Carpool Mobile</h2>
            <p align="right"><a href="registration.html" id="showregistration">Don't have an account? &rarr;</a></p>
                <form method="post" id="loginForm">

                    <label for="password">Email:</label>
                    <input class="required" type="text" name="username" id="username" placeholder="username@target.com">

                    <label for="password">Password:</label>
                    <input class="required" type="password" name="password" id="password" placeholder="password">

                    <input type="button" value="Login" id="submitButton" onClick="handleLogin()">
                </form>
            </div>
        </div>

        <script>
        $(document).ready(function() {
            checkPreAuth();
        });
        </script>
    </body>
</html>

登录Carpool Mobile

电邮: 密码: $(文档).ready(函数(){ checkPreAuth(); });
删除
$(文档).ready(函数()
并将
checkPreAuth();
保存在PhoneGap的deviceready事件中。

您不能在jQuery Mobile中使用下面的一个

$(document).ready(function() {
    checkPreAuth();
});
您需要使用自定义的jQuery Mobile特定事件。您可能需要按以下方式更改代码

$('#page').live('pageshow', function(event){
    checkPreAuth();             
});
检查文档中是否有错误

从您的代码中,我可以注意到您正在使用非常旧的jQuery和jQuery Mobile库。我建议您升级到最新版本,这将使您能够使用比当前版本多得多的功能


下面是一个来自JSFIDLE的示例。

PhoneGap要求您在根目录的“config.xml”文件中手动设置/允许应用程序的各个方面

我相信,您正在寻找的解决方案是:

<access origin="http://code.jquery.com" subdomains="true" />
”并允许其所有子域。这意味着您刚刚解锁了jquery mobile,这正是您想要的,如您的脚本标记所示:


这些“src”属性现在被视为的“子域”,您刚刚成功地允许了它


除了未定义
checkPreAuth();
之外,我对您的代码没有任何问题。您还应该尝试更新query和jquery mobile的版本。
我建议您下载并包含JQuery mobile和JQuery文件(脚本文件)在您的www项目目录中

是否有任何错误?没有,它只是以常规HTML格式显示。如果没有问题,请将您的项目发送给我,我会为您修复。这里的任何内容都不会导致jQM加载时没有其样式。您得到解决方案了吗?我也有同样的问题,即使是简单的页面在添加时也无法工作正在加载jquery mobile js,但没有添加js文件,它在emulator中运行良好。这是一种错误的方法。在加载dom之前不应调用该函数。我在项目中这样做,效果很好。该文件是从本地目录加载的,因此当它碰到脚本标记时,会加载dom。这对于普通的jquery项目是正确的,但对于jquery则不正确移动项目。请查看PhoneGap DOM中Gajotres的精彩解释。DOM总是从本地文件加载。因此,如果您在脚本标记中编写init代码,则不需要进行此检查。我们一直都在这样做。我想您不明白这一点。jQuery Mobile将文件加载到DOM的方式不同(它使用ajax).这可能看起来是正确的,但最终你会发现一些奇怪的错误。嗨,你有没有一个要点可以准确地说明这句话的意思?
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>