-1
我一直在尋找最後兩天,我似乎無法找到解決方案。我的科爾多瓦項目沒有響應jquery
我很努力想要一個小應用程序來列出我們公司所有員工的可搜索列表視圖。儘管我設法讓代碼在模擬器和我的iphone上都能正常工作,但是關於jQuery的創建可搜索列表視圖的部分卻沒有顯示出來。我認爲我通過js和css鏈接進行了雙重和三重檢查,但我仍然無能爲力。任何幫助將非常感激。
順便說一句,我使用Xcode 4.5.2,Jquery-mobile-1.2.0和cordova-2.3。
這裏是index.html的:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<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.mobile-1.2.0.js"></script>
<script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="cordova-2.3.0.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" type="text/css" href="css/styles.css" />
<link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.2.0.min.css" />
</head>
<body>
<div data-role="page">
<div data-role="header" id="header" class="header">
<h1>MIT Employees</h1>
</div><!-- /header -->
<div data-role="content" id="header2">
<h2>Select Employee</h2>
</div><!-- /content -->
<div id="wrapper">
<ul data-role="listview" data-inset="true" data-filter="true"><div data-role="content" id="employeeList"></div></ul>
</div>
<div id="busy"/>Loading...</div>
<script src="js/phonegap.js"></script>
<script src="js/iscroll.js"></script>
<script src="js/getEmpList.js"></script>
<script src="js/employ.js"></script>
</div>
</body>
</html>
而這裏的Javascript:
var db;
var dbCreated = false;
var scroll = new iScroll('wrapper', { vScrollbar: true, hScrollbar:false, hScroll: false });
//add listener when device ready
document.addEventListener("deviceready", onDeviceReady, false);
//function will be called when device ready
function onDeviceReady() {
db = window.openDatabase("EmployeeDirectoryDB", "1.0", "MIT Employee Database", 200000);
if (dbCreated)
db.transaction(getEmployees, transaction_error);
else
db.transaction(populateDB, transaction_error, populateDB_success);
}
function transaction_error(tx, error) {
$('#busy').hide();
alert("Database Error: " + error);
}
function populateDB_success() {
dbCreated = true;
db.transaction(getEmployees, transaction_error);
}
function getEmployees(tx) {
var sql = "select * from employees order by lname, fname";
tx.executeSql(sql, [], getEmployees_success);
}
function getEmployees_success(tx, results) {
$('#busy').hide();
var len = results.rows.length;
for (var i=0; i<len; i++) {
var employee = results.rows.item(i);
$('#employeeList').append('<li data-icon="arrow-r"><a href="employeedetails.html?id=' + employee.id + '">' +
'<p class="line2">' + employee.empid + ' ' + employee.lname + ', ' + employee.fname + '</a></li>');
}
setTimeout(function(){
scroll.refresh();
},100);
db = null;
}