我有我的索引文件作为用户输入用户名和密码的对话框。该页面在它是一个时工作正常,data-role="page
但作为一个对话框,该对话框显示并迅速消失。它基本上会在屏幕上闪烁,我不知道为什么。我的代码如下:
HTML
<body onload="init()">
<div id="home">
<div id="launcherPage" data-role="page">
<!-- I'm just here waiting for deviceReady -->
</div>
<div data-role="dialog" id="loginPage">
<div data-role="header">
<h1>CHUNE</h1>
</div>
<div data-role="content">
<form id="loginForm">
<div data-role="fieldcontain" class="ui-hide-label">
<label for="username">Username:</label>
<input type="text" name="username" id="username" value="" placeholder="Username" />
</div>
<div data-role="fieldcontain" class="ui-hide-label">
<label for="password">Password:</label>
<input type="password" name="password" id="password" value="" placeholder="Password" />
</div>
<input type="submit" value="Login" id="submitButton">
</form>
<div style="text-align: center;">Or</div> <!--need to center-->
<a href="./register.html" data-role="button">Register</a>
</div>
<div data-role="footer">
<h4>© KewsPlus</h4>
</div>
</div>
jQuery
function deviceReady() {
console.log("deviceReady");
$("#loginPage").on("pageinit",function() {
console.log("pageinit run");
$("#loginForm").on("submit",handleLogin);
checkPreAuth();
});
$.mobile.changePage("#loginPage");