pickadate.js根本不工作

时间:2016-06-27 16:27:10

标签: javascript jquery laravel datepicker pickadate

试图学习如何使用这个插件,但我似乎无法做任何事情。有人能指出我正确的方向吗?这是一个laravel项目,但这不应该有很大的不同。

这是我的HTML:

<p><input id="date" class="form-control" ng-model="currentWimDate" placeholder="Date..." type="text"></p>

和我的index.blade.php:

<html lang="en" ng-app="wim">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>WIM(afy)</title>

    <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="css/wimmain.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link rel="stylesheet" href="bower_components/pickadate/lib/themes/default.css" id="theme_base">
    <link rel="stylesheet" href="bower_components/pickadate/lib/themes/default.date.css" id="theme_date">
    <link rel="stylesheet" href="bower_components/pickadate/lib/themes/default.time.css" id="theme_time">

    <script src="bower_components/angular/angular.min.js"></script>
    <script src="bower_components/ng-file-upload-shim/ng-file-upload-shim.min.js"></script>
    <script src="bower_components/ng-file-upload/ng-file-upload.min.js"></script>
    <script src="bower_components/lodash/lodash.js"></script>
    <script src="bower_components/angular-route/angular-route.min.js"></script>
    <script src="bower_components/angular-local-storage/dist/angular-local-storage.min.js"></script>
    <script src="bower_components/restangular/dist/restangular.min.js"></script>

    <script src = "js/app.js"></script>
    <script src = "js/services.js"></script>
    <script src = "js/controllers.js"></script>
    <script src = "js/checkPass.js"></script>
    <script src = "js/signupValidation.js"></script>
    <script src = "js/dropdown.js"></script>
    <script src = "js/profileActions.js"></script>

    <style>

        li {
            padding-bottom: 8px;
        }

    </style>
</head>

<body style="background-color: #ef5350;">       
    <div ng-view></div>


    <script src="bower_components/jquery/dist/jquery.min.js"></script>
    <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="bower_components/pickadate/lib/picker.js"></script>
    <script src="bower_components/pickadate/lib/picker.date.js"></script>
    <script src="bower_components/pickadate/lib/picker.time.js"></script>

    <script type="text/javascript">
    // PICKADATE FORMATTING
    $('#date').pickadate({
        format: 'mmmm d, yyyy',     // Friendly format displayed to user
        formatSubmit: 'mm/dd/yyyy', // Actual format used by application
        hiddenName: true            // Allows two different formats
    });
    </script>
</body>

我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

我认为在Angular完成将#date放入HTML之前,您的jQuery代码正在运行。因此jQuery无法找到您正在寻找的元素,因此没有任何反应。您可以通过输出$('#date')的结果来测试它。在Angular完成渲染后尝试运行pickadate代码。这是一个question可能会帮助你。