我有以下代码在附加到输入的日期选择器上工作正常,但在与内联日期选择器一起使用时不运行 beforeshow 和 beforeshowday 部分。
我能做些什么来解决这个问题?
$('.mydate').datepicker({
showWeek: true,
firstDay: 1,
dateFormat: 'yy, m, d',
minDate: 0,
maxDate: '+2Y',
showOtherMonths: true,
selectOtherMonths: true,
numberOfMonths: 2,
beforeShow: function(input, inst) {
selectdatesElem = $(input).siblings("div").find("select.startdates");
$(input).siblings("div").find("select.startdates").find("option").each( function() {
startDates.push($(this).val())
});
$(input).siblings("div").find("select.availdates").find("option").each( function() {
eventDates.push($(this).val())
});
},
beforeShowDay: function(date) {
for (var i = 0; i < eventDates.length; i++) {
if (date.getFullYear()+", "+date.getMonth()+", "+date.getDate() == eventDates[i]) {
return [false, 'eventDay'];
}
}
for (var i = 0; i < startDates.length; i++) {
if (date.getFullYear()+", "+date.getMonth()+", "+date.getDate() == startDates[i]) {
return [true, 'eventDay'];
}
}
return [false, ''];
},
onSelect: function(dateText, input, inst) {
var selectedDateParts = dateText.split(',');
selectdatesElem.val(parseInt(selectedDateParts[0]) + ", " + (parseInt(selectedDateParts[1])-1) + ", " + parseInt(selectedDateParts[2])).change();
}
});