我正在使用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
我不知道我哪里出错了。有什么建议吗?
答案 0 :(得分:0)
您可以将一个整数数组传递给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>
&#13;