我正在构建一个以登录表单开头的 WebWorks 应用程序,如果登录成功,则应该显示带有 id='map' 的第二个页面。我尝试使用 $.mobile.changePage 来显示页面,但它只会重新加载登录页面。为什么不加载第二页?
我删除了所有登录验证代码以简化操作,以便找出 changePage 不起作用的原因。
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<link rel="stylesheet" href="lib/BlackBerry-JQM-all-1.0.0.css" />
<script src="lib/BlackBerry-JQM-all-1.0.0.js"></script>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBHGb5Si_2oXtOLCo_IzRIJPtrKkhyFPsU&sensor=false"></script>
</head>
<body>
<div data-role="page" id="login">
<div data-role="header">
<h1>TCOB - Login</h1>
</div>
<!-- /header -->
<div data-role="content">
<div class="BB10Container">
<form method="post">
<label for="username">Username</label>
<input type="text" name="user-input" id="username" placeholder="Username"/>
<label for="basic">Password</label>
<input type="password" name="pass-input" id="password" placeholder="Password"/>
<input type="submit" data-role="button" data-inline="true" data-icon="check" value="Submit" id="submit">
</form>
</div>
</div>
<!-- /content -->
<div data-role="footer" data-position="fixed">
</div>
</div>
<div data-role="page" id="map" >
<div data-role="header">
<h1>TCoB</h1>
</div>
<div data-role="content">
</div>
<div data-role="footer" data-position="fixed">
</div>
</div>
</div>
<script>
$(document).bind("mobileinit", function() {
$.mobile.page.prototype.options.backBtnText = "Zurück";
});
$('#username').keyup(function(){
$.get("http://www.hedonsoft.com/tcob/php/check_user.php",{username: $("#username").val()},function(data){
if(data == true){
$('#username').css("background-color","#00FFFF").css("color","#000000");
}else{
$('#username').css("background-color","#000000").css("color","#FFFFFF");
}
});
});
$('#submit').click(function(){
$.mobile.changePage("#map");
});
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
}
function getLocation(){
}
</script>
</body>
</html>