我有这个代码,我希望将选项限制为仅由诊所选择的日期。
$("#datepicker").datepicker({
dateFormat: "yy-mm-dd",
numberOfMonths: 3,
showButtonPanel: true,
beforeShowDay: function(date) {
var day = date.getDay();
var clinic = $("#AppointmentClinicId").val();
console.log("day:" + day);
console.log("selected clinic:" + clinic);
if (clinic == 1) {
return [(date.getDay() == 1), ""];
}
if (clinic == 2) {
return [(date.getDay() == 2), ""];
}
if (clinic == 3) {
return [(date.getDay() == 3), ""];
}
if (clinic == 4) {
return [(date.getDay() == 4), ""];
}
if (clinic == 5) {
return [(date.getDay() == 5), ""];
}
if (clinic == 6) {
return [(date.getDay() == 6), ""];
}
/*if (clinic == 0) {
return [true, ""];
}*/
//return [true,''];
}
}).val();
然而,它始终显示一个总是返回假的诊所。如果你删除beforeShowDay,它的工作原理。我知道“返回[true,''];”,如果我只有那个,它就有效。但是,无法弄清楚为什么它没有正确地选择诊所以显示允许的日期。
请帮忙!
答案 0 :(得分:-1)
您尝试使用的功能不是beforeShowDay
,而是onBeforeShowDay