【问题标题】:enabledHours in bootstrap-datetimepicker-3bootstrap-datetimepicker-3 中的 enabledHours
【发布时间】:2017-08-27 13:52:32
【问题描述】:

我正在与 http://eonasdan.github.io/bootstrap-datetimepicker/ 合作。我知道这不再受支持,但我也在使用 rails,这让我的生活变得更加轻松。 我想要做的是将启用时间设置为一系列值。这是我所拥有的:

scheduleHandle.onclick = function (){
    $('#schedule_date_time_of_class').datetimepicker({
        inline: true,
        sideBySide: true,
        enabledHours: [[moment().hour(14).minutes(0), moment().hour(17).minutes(0)]]
    });
};

这是我得到的错误:

Uncaught Tried 24 times to find a valid date
picker.enabledHours @ bootstrap-datetimepicker.self-9bf8b50ba86095fb5caaadd1ee11eaf661b3f4879f3ea5263d541e9804fd7b15.js?body=1:2188
(anonymous) @ bootstrap-datetimepicker.self-9bf8b50ba86095fb5caaadd1ee11eaf661b3f4879f3ea5263d541e9804fd7b15.js?body=1:1430
each @ jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:377
picker.options @ bootstrap-datetimepicker.self-9bf8b50ba86095fb5caaadd1ee11eaf661b3f4879f3ea5263d541e9804fd7b15.js?body=1:1428
dateTimePicker @ bootstrap-datetimepicker.self-9bf8b50ba86095fb5caaadd1ee11eaf661b3f4879f3ea5263d541e9804fd7b15.js?body=1:2252
(anonymous) @ bootstrap-datetimepicker.self-9bf8b50ba86095fb5caaadd1ee11eaf661b3f4879f3ea5263d541e9804fd7b15.js?body=1:2285
each @ jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:371
each @ jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:138
$.fn.datetimepicker @ bootstrap-datetimepicker.self-9bf8b50ba86095fb5caaadd1ee11eaf661b3f4879f3ea5263d541e9804fd7b15.js?body=1:2280
scheduleHandle.onclick @ 51:150

我不知道我哪里出错了。有什么建议吗?

【问题讨论】:

    标签: ruby-on-rails twitter-bootstrap bootstrap-datetimepicker eonasdan-datetimepicker


    【解决方案1】:

    您可以将整数数组传递给enabledHours,设置您想要禁用的小时数。

    这是一个工作示例:

    $('#schedule_date_time_of_class').datetimepicker({
      inline: true,
      sideBySide: true,
      enabledHours: [ 14, 15, 16 ]
    });
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
    
    <div class="form-group">
      <div class='input-group date' id='schedule_date_time_of_class'>
        <input type='text' class="form-control" />
        <span class="input-group-addon">
          <span class="glyphicon glyphicon-calendar"></span>
        </span>
      </div>
    </div>

    【讨论】:

      猜你喜欢
      • 2014-08-10
      • 1970-01-01
      • 2021-04-17
      • 1970-01-01
      • 1970-01-01
      • 2017-05-05
      • 2014-04-25
      • 2016-03-13
      • 1970-01-01
      相关资源
      最近更新 更多