我正在使用引导日期选择器来启用特定日期,但是当前面临的问题是,无论何时我选择日期,我都无法在更改月份保留所选的日期。每当我单击“更改月份”视图时,都会刷新,我无法保存所选的值。如果我将日期选择为12月3日,那么每次返回时都应该选择12月3日泡沫?
HTML代码
<div class="delivery-datepicker" id="deliveryDatePicker-LD"></div>
jQuery代码
var enabledDateArr = ["2018-11-28", "2018-11-29", "2018-11-30", "2018-12-1", "2018-12-2", "2018-12-3", "2018-12-4", "2018-12-5", "2018-12-6"];
$('.delivery-datepicker').datepicker({
startDate: '-',
format: 'yyyy-mm-dd',
endDate: '-',
updateViewDate: false,
todayHighlight: false,
changeMonth: true,
changeYear: false,
templates: {
leftArrow: '<i class="genesis-icon-arrow-left-2"></i>',
rightArrow: '<i class="genesis-icon-arrow-right-2"></i>'
},
beforeShowDay:function(date){
var dt_yyyymmdd=date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();
if(enabledDateArr.indexOf(dt_yyyymmdd)!=-1){
return{
tooltip:'This date is enabled',
classes: 'alwaysActive',
enabled: true
};
}else{
return false;
}
},
}).on('changeDate', function (e) {
console.log("change date")
let date = "";
date = e.date.getFullYear();
if((e.date.getMonth() + 1) < 10) {
date = date + "-" + "0" + (e.date.getMonth() + 1)
} else {
date = date + "-" + (e.date.getMonth() + 1)
}
if((e.date.getDate()) < 10) {
date = date + '-' + "0" + (e.date.getDate())
} else {
date = date + '-' + (e.date.getDate())
}
})
CSS代码
.alwaysactive{opacity: 1 !important;}
任何人都可以帮助我解决此问题,或者给我一些如何解决的建议吗?