2012-01-30 79 views
0

我正在開發應用程序在eclipse中使用phonegap android。我已創建文件夾結構assets-> jquery.mobile folderI已經把jquery庫文件jquery.mobile-1.0rc2 .min.js等二十多個國家資產 - > WWW文件夾將HTML文件。我有包括HTMLjs事件不會觸發使用jquery mobile和phoengap for android

<script type="text/javascript" src="jquery.mobile/jquery-1.6.4.min"></script> 
    <script type="text/javascript" charset="utf-8" src="phonegap-1.1.0.js"></script> 
    <script type="text/javascript" src="jquery.mobile/jquery.mobile-1.0rc2.min.js"></script> 

jQuery庫文件,HTML文件中我寫的代碼

<script type="text/javascript"> 
$(function() { 
$('body').bind('taphold', function(e) { 
alert('You tapped and held!'); 
e.stopImmediatePropagation(); 
return false; 
}); 
$('body').bind('swipe', function(e) { 
alert('You swiped!'); 
e.stopImmediatePropagation(); 
return false; 
}); 
}); 

我加入的PhoneGap JAR並把插件xml文件放入xml文件夾中,誰能告訴問題是什麼問題要解決它?

感謝

回答

0

你錯過<\script>

下的index.html成功運行了我。 (請注意,我用的PhoneGap-1.3.0和jQuery移動-1.0上運行,但我希望的舊版本,爲這一計劃運行良好。)

<!DOCTYPE HTML> 
<html> 
    <head> 
    <meta name="viewport" content="width=320; user-scalable=no" /> 
    <meta http-equiv="Content-type" content="text/html; charset=utf-8"> 
    <title>PhoneGap Demo With JQuery Mobile</title> 
     <link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.0.css" type="text/css"/> 
     <link rel="stylesheet" href="pgandjqm-style-override.css" type="text/css"/> 
     <script type="text/javascript" charset="utf-8" src="jquery.mobile/jquery-1.6.4.min"></script> 
     <script type="text/javascript" charset="utf-8" src="phonegap-1.3.0.js"></script> 
     <script type="text/javascript" charset="utf-8" src="jquery.mobile/jquery.mobile-1.0.js"></script> 

<script type="text/javascript"> 
$(function() { 
$('body').bind('taphold', function(e) { 
alert('You tapped and held!'); 
e.stopImmediatePropagation(); 
return false; 
}); 
$('body').bind('swipe', function(e) { 
alert('You swiped!'); 
e.stopImmediatePropagation(); 
return false; 
}); 
}); 
</script> 
    </head> 
    <body > 
    </body> 

+0

我需要main.js文件運行在eclipse中的應用程序應用程序的android – kumar 2012-01-31 06:34:10

+0

不,index.html是完整的。 – 2012-01-31 16:12:40

0

首先,您的參考文件的版本太舊。請更新它們。最新:phonegap-> 2.4,jquery-> 1.9.1,jqm-> 1.3。 其次,您需要檢查您的phonegap項目是否以正確的方式創建。您下載的最新phonegap將有一個完美配置的測試項目。您也可以使用官方命令行方式使用標準模板創建項目。第三,你可以使用'ondeviceready'事件來綁定你的測試函數。如果它不起作用,你的phonegap配置必須是錯誤的,你需要再次檢查。