A few dates in bootstraps.

I am trying to select multiple dates in Boostrap-Datepicker.

I installed the datepicker as such, just fine.

$('#datepicker2').datepicker();

Now I want to select some dates in the calendar:

$('#datepicker2').datepicker('setDate', [new Date(2014, 2, 5),new Date(2014, 3, 5)]);

This does not work. Errors are not logged, but no dates are selected.


EDIT: The datepicker version that I used had a multi-page problem, I used the previous version and it works - maybe the version problem


This works fine, though:

$('#datepicker2').datepicker('setDate', new Date(2014, 2, 5));
+4
source share
1 answer

Using options, you first need to define your feedpicker as a multi-tasking selector.

$('#datepicker2').datepicker({
  multidate: true
});

setDates:

$('.date').datepicker({
    multidate: true
});

$('.date').datepicker('setDates', [new Date(2014, 2, 5), new Date(2014, 3, 5)])
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker.js"></script>
<input type="text" class="form-control date"/>
Hide result
+13

All Articles