Bootstrap Datetimepicker 不工作 MVC 4

Bootstrap Datetimepicker not working MVC 4

过去几天我一直在尝试使用这个 datetimepicker,无论我怎么努力,我能得到的就是左上角出现的日历。我找不到任何关于如何实施控件的真正教程,并且该站点上过去的答案也没有帮助。

这是我现在拥有的:

查看

@Scripts.Render("~/Scripts/knockout-3.4.0.js")
@Scripts.Render("~/Scripts/jquery-1.10.2.js")
@Scripts.Render("~/bundles/bootstrap")
@Styles.Render("~/Content/css")
<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" />

<div class="container">
  <div class="row">
    <div class='col-sm-6'>
      <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>

<script>
  $(function() {
    $('#datetimepicker1').datetimepicker();
  });
</script>

关于解决日历字形与输入间隔开的第二个问题,您需要执行以下任一操作(您的偏好):

<div class="row">
  <div class='col-sm-6' /*change this to col-sm-3 or any that is below 6*/>
  <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 class="row">
  <div style="width: 25%;/*or something close to that*/" class='col-sm-6'>
    <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>

也只是一个挑剔的东西..尽量让你的 ScriptsStyles 在一起,不要相互混合.. 更容易阅读。

js脚本"bootstrap-datetimepicker" 需要先加载 Moment.js 和 Jquery.js。

   bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js",
                    "~/Scripts/bootstrap.js",
                    "~/Scripts/bootstrap.min.js",
                    "~/Scripts/moment.js",
                    "~/Scripts/moment.min.js",
                    "~/Scripts/modernizr-2.6.2.js",
                    "~/Scripts/bootstrap-datetimepicker.js"));