Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
262 views
in Technique[技术] by (71.8m points)

javascript - Error With Bootstrap 3 Date/Time Picker

I am using the date/time picker from Eonasden that you can find here. Date Time Picker

I am using HTML from the example:

<div class="container">
    <div class="col-md-10">
        <div class='well'>
            <div class="form-group">
                <div class='input-group date' id='datetimepicker1'>
                    <input type='text' class="form-control" />
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
            </div>
        </div>
    </div>
</div>

It displays the icon fine, but not the calendar drop down. My head script is:

<link href="view/dist/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="view/dist/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<link href="http://cdnjs.cloudflare.com/ajax/libs/jasny-bootstrap/3.0.1-p7/css/bootstrap.min.css" rel="stylesheet" >

<script src="http://code.jquery.com/jquery.js"></script>
<script src="view/dist/js/bootstrap.min.js"></script>
<script src="view/dist/js/bootstrap-datetimepicker.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jasny-bootstrap/3.0.1-p7/js/bootstrap.min.js"></script>

$(function() {

  $( document ).ajaxStop( function() {
    $('#datetimepicker1').datetimepicker();
  });

});

I receive a console error of "Uncaught ReferenceError: moment is not defined" Does anyone have an idea on how to fix this? It seems to work fine on his sample page.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

According to the examples, you need to include this to..

http://momentjs.com/

It has to be after bootstrap.js, but before the datetimepickerjs like this..

<script type="text/javascript" src="scripts/bootstrap.min.js"></script>
<script type="text/javascript" src="scripts/moment-2.4.0.js"></script>
<script type="text/javascript" src="scripts/bootstrap-datetimepicker.js"></script>

It shows it on the GitHub readme..

"Datetimepicker requires moment.js."


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...