Bootstrap日期选择器中的多个日期 [英] Multiple dates in Bootstrap date-picker
问题描述
我试图在 Boostrap-Datepicker。中选择多个日期。
我已经初始化了datepicker这样很好。
$('#datepicker2')datepicker();
现在我想要选择多个日期在日历上:
$('#datepicker2')。datepicker('setDate',[new Date(2014,2,5),new Date(2014,3,5)]);
它不工作。没有错误记录,但未选择日期。
编辑: datepicker版本I使用了多个问题,我使用了以前的版本,它可以工作 - 可能是一个版本问题
工作很好,但是:
$('#datepicker2')。datepicker('setDate',new Date 2014,2,5));
有必要首先将您的datepicker定义为multidate选择器通过选项。
$('#datepicker2')。datepicker({
multidate:true
});
然后,您可以通过 setDates
方法:
< 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 =textclass =form-control date/>
I am trying to select multiple dates in Boostrap-Datepicker.
I have intialized the datepicker as such, just fine.
$('#datepicker2').datepicker();
Now I want to select multiple dates on the calendar:
$('#datepicker2').datepicker('setDate', [new Date(2014, 2, 5),new Date(2014, 3, 5)]);
It's not working. No errors are logged but the dates are not selected.
EDIT: the datepicker version I used had some issue with multidates, I used a previous version and it works - probably a version issue
This works just fine though:
$('#datepicker2').datepicker('setDate', new Date(2014, 2, 5));
It is necessary to first define your datepicker as a multidate picker through the options.
$('#datepicker2').datepicker({
multidate: true
});
Then you can set your dates via the setDates
method :
$('.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"/>
这篇关于Bootstrap日期选择器中的多个日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!