1

我已经尝试了好几个小时来完成这项工作。login.js 中的测试pageinitpageshow第 1 行都没有任何响应,但是页面仍在加载中,当我在 FF 中运行它时没有收到任何 javascript 错误。

来自 index.html

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">    
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>PSForum Notiser</title>
    <link rel="stylesheet" href="js/jquery.mobile/jquery.mobile-1.3.2.min.css" />
    <script type="text/javascript" src="phonegap.js"></script>
    <script src="js/jquery.mobile/jquery-1.9.1.min.js"></script>
    <script src="js/jquery.mobile/jquery.mobile-1.3.2.min.js"></script>
    <script src="js/main.js"></script>
    <script src="js/login.js"></script>
</head>

来自 login.html

<div id="loginPage" data-role="page">

    <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>

</div>

来自 login.js(不希望运行的部分)

$("#loginPage").on('pageinit', function(){
    alert("Hello world!");
    console.log("loginPage is loaded");
    checkPreAuth();
    var form = $("#loginForm");
    $(form).on("submit",handleLogin);

    if(window.localStorage["username"] != undefined) {
      $("#username", form).val(window.localStorage["username"]);
    }
});

希望stackoverflow的智慧能帮我找到为什么$("#loginPage").on('pageinit')不开火?

此致

4

0 回答 0