单击时,Bootstrap日期选择器不会出现

时间:2015-12-09 09:43:05

标签: javascript jquery css twitter-bootstrap datepicker

我正在尝试将一个日期选择器添加到我的一个表单字段中,但它根本不会出现。当我将鼠标悬停在图标上时,手按钮就会出现,就好像它是可点击的一样,但当我点击它时,没有任何反应。这是我的代码:

<script type="text/javascript" src="/scripts/jquery.min.js"></script>
<script type="text/javascript" src="/scripts/moment.min.js"></script>
<script type="text/javascript" src="/scripts/bootstrap.min.js"></script>
<script type="text/javascript" src="/scripts/bootstrap-datetimepicker.*js"></script>
<link rel="stylesheet" href="/Content/bootstrap-datetimepicker.css" />

@using (Html.BeginForm("Index", "Engagement", FormMethod.Get, new { @class = "form-inline" }))
{
    <div class="form-group">
        <label for="end">Start date:</label><br />
        <div class='input-group date' id='StartDateFilter'>
            <input type='text' class="form-control" />
            <span class="input-group-addon">
                <span class="glyphicon glyphicon-calendar"></span>
            </span>
        </div>
    </div>

    <script type="text/javascript">
        $(function () {
        $('#StartDateFilter').datetimepicker({
            locale: 'en-GB'
            });
        });
    </script>
}

1 个答案:

答案 0 :(得分:1)

jurfer我认为,脚本顺序不正确。这是有效的代码

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js" />

<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/src/js/bootstrap-datetimepicker.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

<link rel="stylesheet" href="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/build/css/bootstrap-datetimepicker.css" />


 <div class="container">
    <div class="row">
        <div class='col-sm-6'>
            <div class="form-group">
                <div class='input-group date' id='dt1'>
                    <input type='text' class="form-control" />
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
            </div>
        </div>
        <script type="text/javascript">


            $('#dt1').datetimepicker({
            locale: 'en-GB'
            });
        </script>
    </div>
</div>