I am using Bootstrap 3 Datepicker on a page with 2 timepickers - when I use them together I get an error:
enabledHours()
expects an array parameter
If I run just one then I don't get any error.
Here is the code I am using for the picker:
jQuery(document).ready(function () {
$('.datetimepicker1').datetimepicker({
showClose: true,
format: "HHmm",
enabledHours: [14, 15, 16, 17, 18],
sideBySide: true
});
});
I have created a fiddle which recreates this at https://jsfiddle.net/zgyd1qqd/1/
Additionally, I also did a fiddle with the same code (https://jsfiddle.net/zgyd1qqd/2/) but with only one picker initialized and the error is not present so, I assume, the format etc of enabledHours
is actually OK?
Is there something else wrong in my code?
It's probably because the array is referenced by both datepickers.
You could avoid this by iterating over each of the elements you are initializing the datepicker on:
$('.datetimepicker').each(function () {
$(this).datetimepicker({
showClose: true,
format: "HHmm",
enabledHours: [14, 15, 16, 17, 18],
sideBySide: true
});
});