我使用下面的代碼與PhoneGap的編程方式更改的頁面在我的應用程序中切換分頁:
$('#selection').change(function() {
alert($(this).val());
$.mobile.changePage($("#about"), "slideup");
});
當用戶改變選擇,警報發生在理論上應該發送給下面的jquery對象。
<div data-role="page" id="about" data-id="about">
<div data-role="header" data-position="fixed" data-nobackbtn=」false」><h1>About Us</h1></div>
<div data-role="content">
<p>Information about the company</p>
</div>
</div>
對象正常工作與正常連接
<span><a href="#about" data-transition="fade">About Us</a></span>
但我不能讓它在瀏覽器或手機間隙內programmtically加載。
任何想法?我一定會查找API一百萬次。
完整的HTML如下:
<!DOCTYPE HTML>
<html>
<head>
<title>Header</title>
<script type="text/javascript" charset="utf-8" src="js/phonegap-0.9.3.js"></script>
<link rel="stylesheet" href="css/jquery.mobile-1.0a1.min.css" />
<script src="js/jquery-1.4.3.min.js"></script>
<script src="js/jquery.mobile-1.0a1.min.js"></script>
<script src="js/mycustomjs.js"></script>
<script type="text/javascript">
// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
//
function onDeviceReady() {
function reachableCallback(reachability) {
// There is no consistency on the format of reachability
var networkState = reachability.code || reachability;
var states = {};
states[NetworkStatus.NOT_REACHABLE] = 'No network connection';
states[NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK] = 'Carrier data connection';
states[NetworkStatus.REACHABLE_VIA_WIFI_NETWORK] = 'WiFi connection';
alert('Connection type: ' + states[networkState]);
}
navigator.network.isReachable('phonegap.com', reachableCallback);
}
</script>
</head>
<body>
<!-------------- INDEX PAGE ------------------------------------>
<div data-role="page" id="home">
<div data-role="header" data-position="fixed" data-nobackbtn=」false」>
<h1 header</h1>
</div>
<div data-role="content">
<p>Thank you for downloading our app</p>
<div data-role="fieldcontain">
<label for="selection" class="select">Please select an industry</label>
<select name="selection" id="selection">
<option value="choice1">choice1</option>
</select>
</div>
</div>
</div>
<!-------------- ABOUT PAGE ------------------------------------>
<div data-role="page" id="about" data-id="about">
<div data-role="header" data-position="fixed" data-nobackbtn=」false」>
<h1>About Us</h1>
</div>
<div data-role="content">
<p>Information about the company</p>
</div>
</div>
</body>
</html>
嗨,該代碼爲我工作(與jQuery Mobile的1.0b2)。請參閱https://gist.github.com/1164723您可以顯示完整的HTML嗎? – Zaki
已完成html添加。 – Billie