【发布时间】:2016-10-26 18:42:03
【问题描述】:
http://bootstrap-datepicker.readthedocs.io/en/latest/markup.html
我有一个内联日期选择器,其中多日期设置为 true。我需要用户在日历中选择有效的一天或多天。如何从我的按钮返回选定的日期? getDates 按照说明不返回日期数组???
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker.css" rel="stylesheet"/>
<div class="datepicker" data-date-format="mm/dd/yyyy"></div>
<button type="button" class="btn btn-primary btn_save">Save</button>
<script>
$(document).ready(function () {
$('.datepicker').datepicker({
format: 'mm/dd/yyyy',
multidate: true,
daysOfWeekDisabled: [0, 6],
clearBtn: true,
todayHighlight: true,
daysOfWeekHighlighted: [1, 2, 3, 4, 5]
});
$('.datepicker').on("changeDate", function () {
var the_dates = $('.datepicker').datepicker('getDates');
//this does not work
console.log(the_dates)
});
$(document).on('click', ".btn_save", function (e) {
var the_dates = $('.datepicker').datepicker('getDates');
//this does not work
console.log(the_dates)
});
});
</script>
【问题讨论】:
-
不是答案,但该项目看起来有点粗略。他们有 465 open issues 和 64 open pull requests 对于这种规模的项目来说似乎很多......
-
我需要一个引导日期选择器,我可以在其中选择一天,这是我能找到的唯一一个。找到了一个 Jquery,但是当我的整个项目都是引导程序时,这是一个样式问题。
标签: javascript jquery twitter-bootstrap datepicker