科尔多瓦无法点击输入

时间:2016-05-23 19:55:06

标签: html ios cordova

之前我已经构建了几个Cordova应用程序,并且通常将' index.html'到一个'app.html'使用window.location = app.html

进行身份验证后

在我的最新应用中,当我退出我的应用程序(点击app.html中的按钮)时,我被正确地重定向到我的index.html,但是一旦我在那里,我就无法点击任何一个表单尝试重新登录的输入。我能让它工作的唯一方法是关闭并重新打开应用程序。

另外,如果我直接通过safari或chrome运行html页面,但是在iOS sim上运行时我无法点击这些输入,那么发布的代码可以正常工作



        access_token = localStorage.getItem('access_token')
        user_id = localStorage.getItem('user_id')

        if(access_token != undefined && user_id != undefined) {
            window.location = 'app.html'
        }

        $("#login-form").submit(function(ev) {
                ev.preventDefault()

                data = $(this).serialize()

                $.ajax({
                    method: "post",
                    url: 'https://*******.io/api/login',
                    data: data,
                    success:function(result) {
                        token_object = JSON.parse(result)
                        localStorage.setItem('access_token', token_object.access_token);
                        localStorage.setItem('user_id', token_object.user_id);
                        window.location = 'app.html'
                    },
                    statusCode: {
                        401: function() {
                            $("#error-container").removeClass('hidden').html('Email/Password combination was not found.');
                        },
                        500: function() {
                            $("#error-container").removeClass('hidden').html('A server error has occured');
                        }
                    }
                })
            })

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">

        <!-- Stylesheets -->
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <link rel="stylesheet" type="text/css" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="bower_components/jquery-ui/themes/smoothness/jquery-ui.min.css">
        <link rel="stylesheet" type="text/css" href="bower_components/font-awesome/css/font-awesome.min.css">


        <!-- Javascripts -->
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="bower_components/jquery/dist/jquery.min.js"></script>
        <script type="text/javascript" src="bower_components/jquery-ui/jquery-ui.min.js"></script>
        <script type="text/javascript" src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="js/jquery-loadtemplate.js"></script>
        <title>MyApp</title>
    </head>
    <body>
        <!-- 3. Display the application -->
        <div class="container container-fluid login-container">
            <div class="row">
                <div class="col-xs-12 text-center">
                    <h1 class="text-center">
                        <i class="fa fa-map-marker"></i>
                        My App
                    </h1>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12 col-md-8 col-md-offset-2 text-center">
                    <form id="login-form">
                        <div id="error-container" class="form-group hidden"></div>
                        <div class="form-group">
                            <input type="email"  class="form-control" name="email" id="email" placeholder="Email">
                        </div>
                        <div class="form-group">
                            <input type="password" class="form-control" name="password" placeholder="Password">
                        </div>

                        <div class="clearfix"></div>

                        <button class="btn btn-default">
                            <i class="fa fa-sign-in"></i>
                            Login
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </body>
        
&#13;
&#13;
&#13;

0 个答案:

没有答案