简体   繁体   English

单击时 Bootstrap DateTimePicker 不显示日历

[英]Bootstrap DateTimePicker not showing calendar when clicked

recently I tried to use Bootstrap DateTimePicker in my ASP.NET MVC project, and the calendar just wont show up.最近我尝试在我的ASP.NET MVC项目中使用Bootstrap DateTimePicker ,但日历不会显示。 I believe I already put the Scripts and CSS in the right order.我相信我已经按照正确的顺序放置了脚本和 CSS。

Here is my CSS and Scripts :这是我的 CSS 和脚本:

 <link href="~/Content/css/bootstrap.min.css" rel="stylesheet" />
 <link href="~/Content/bootstrap-datetimepicker.min.css" rel="stylesheet" />

<script src="~/Scripts/jquery-3.4.1.min.js" type="text/javascript"></script>
<script src="~/Scripts/moment.min.js" type="text/javascript"></script>
<script src="~/Scripts/bootstrap.min.js" type="text/javascript"></script>
<script src="~/Scripts/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
@RenderSection("Scripts", required: false)

And this is my View Page :这是我的查看页面:

<div class="col-md-3">
   <div class="form-group">
       <label>Tanggal Survey </label>                          
          <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>

@section Scripts{
    <script type="text/javascript">
        $(function () {
            $('#datetimepicker1').datetimepicker({
                format: 'DD MMMM YYYY'
            });
        });

    </script>
}

And when I click the input, it just show the date and never show the pop-up calendar , here is the example当我点击输入时,它只显示日期,从不显示弹出日历这是示例

Check the examples here: minimum setup在此处查看示例: minimum setup

For your datepicked to open with clicking on the input you need to remove the glyph and go with the minimum setup.要通过单击输入来打开您的日期选择,您需要删除字形并使用最小设置。

<div class="container">
    <div class="row">
        <div class='col-sm-6'>
            <input type='text' class="form-control" id='datetimepicker4' />
        </div>
        <script type="text/javascript">
            $(function () {
                $('#datetimepicker4').datetimepicker();
            });
        </script>
    </div>
</div>

Otherwise you can do this:否则你可以这样做:

$(function() {
  $('.datetimepicker').datetimepicker();

  $('.datetimepicker-addon').on('click', function() {
    $(this).prev('input.datetimepicker').data('DateTimePicker').toggle();
  });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM