我的 WordPress 项目中有一个 jQuery dateTimePicker。选择器运行良好,但是当我选择日期下拉菜单并尝试用鼠标滚轮滚动时,年份不会滚动。相反,月份会发生变化..知道如何让日期下拉菜单正确滚动年份吗?
这是我的 JS 代码:
var preferredDateTimePicker = $('#preferred-date-time .preferred-datetimepicker');
preferredDateTimePicker.datetimepicker({
disabledDates : disabledDates, formatDate:'d-m-Y',
allowTimes : allowTimes,
minDate : 0,
format : 'd-m-Y H:i:s',
inline : true,
onGenerate:function( ct ){
$(this).find('.xdsoft_date.xdsoft_weekend').addClass('xdsoft_disabled');
},
onClose: function(dateText, inst) {
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, 1, 1));
},
onChangeDateTime:function(dp,input){
getCalenderValue = preferredDateTimePicker.val();
newCalenderDate = getCalenderValue.split(' ')[0];
var selectedBlockDateTime = $.map(disabledDatetime, function(value, key) {
if(newCalenderDate == key){
var obj = {};
obj['blockDate'] = key;
obj['blockTime'] = value;
return obj;
}
});
if(selectedBlockDateTime.length){
var blockDate = selectedBlockDateTime[0].blockDate;
var blockTime = selectedBlockDateTime[0].blockTime;
var allowTimeSelected = arrayDiff(blockTime,allowTimes);
console.log("allowTimeSelected", allowTimeSelected);
if( newCalenderDate == blockDate){
if (allowTimeSelected.length === 0) {
this.setOptions({
disabledDates : blockDate
});
}else{
this.setOptions({
allowTimes: allowTimeSelected
});
}
}
}else{
this.setOptions({
allowTimes : allowTimes,
});
}
}
});