1
我正在使用一个非常简单的应用程序,它使用Jquery Mobile和Cordova.js,我使用phonegap模拟器在我的iPhone上运行de应用程序,将它连接到phonegap v0.1.9。在索引文件我有以下代码:Cordova和Jquery Mobile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=yes" />
<meta name="msapplication-tap-highlight" content="no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="js/cordova.js"></script>
<script src="http://servicios.usig.buenosaires.gov.ar/usig-js/2.4/usig.MapaInteractivo.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/index.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.5.min.css" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<script>
var deviceReadyDeferred = $.Deferred();
var jqmReadyDeferred = $.Deferred();
$(document).on("mobileinit", function() {
alert("mobile init");
jqmReadyDeferred.resolve();
});
function init() {
document.addEventListener("deviceReady", deviceReady, false);
function deviceReady() {
alert("device Ready");
deviceReadyDeferred.resolve();
}
$.when(deviceReadyDeferred,jqmReadyDeferred).then(onDeviceReady);
}
function onDeviceReady() {
// Now safe to use the Cordova API
alert("End of init");
app.initialize();
}
</script>
<script type="text/javascript" src="js/jquery.mobile-1.4.5.min.js"></script>
<title>My app</title>
</head>
<body onload="init()">
<div data-role="page">
</body>
</html>
我真的不知道,如果我打电话的.js文件的方式是正确的,但它是我得到它的工作或多或少的方式。 使用Chrome插件我可以模拟我的手机,并且所有功能都按预期的顺序工作。但是,当我在手机上运行应用程序uning phonegap模拟器来运行应用程序时,它会加载Jquery,并且必须将其最小化,然后恢复de应用程序以使设备调用被触发。 我是否以错误的方式调用函数?或者它是一个手机模拟器问题? 感谢您的帮助!