我正在开发一个使用jQuery Mobile的PhoneGap应用程序。上一次我在这个项目上工作时,它看起来很棒,但现在jQuery手机停止了工作。到底怎么回事?
下面是我的代码:
<!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? →</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>
发布于 2013-06-28 04:58:35
PhoneGap要求您在根目录下的"config.xml“文件中手动设置/允许应用程序的各个方面。
我相信,您正在寻找的解决方案是这一行:
<access origin="http://code.jquery.com" subdomains="true" />
您正在允许访问"http://code.jquery.com“的外部资源,并允许访问其所有子域。这意味着您已经解锁了jquery mobile,这就是您要做的,如您的脚本标记所示:
这些"src“属性现在被视为http://code.jquery.com的”子域“,您刚刚成功地允许了!
发布于 2013-03-20 11:54:46
您不能在jQuery移动版中使用以下版本
$(document).ready(function() {
checkPreAuth();
});
您需要使用自定义的jQuery移动特定事件。您可能需要更改代码,如下所示。
$('#page').live('pageshow', function(event){
checkPreAuth();
});
查看有关more relevant events的文档。
从您的代码中,我可以注意到您使用的是非常旧的jQuery和jQuery移动库。我建议您升级到最新的library,这将使您能够使用比当前版本更多的功能。
下面是一个来自jsfiddle的latest framework示例。
发布于 2014-12-10 23:12:37
除了checkPreAuth();
没有定义之外,我对你的代码没有任何问题。您还应该尝试更新您的query和jquery mobile版本。我建议您下载并包含www项目目录中的JQuery移动和Jquery文件(脚本文件)。
https://stackoverflow.com/questions/15510100
复制相似问题