我有这段代码,我想将选项限制为仅由诊所选择的日期。
$("#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();
但是,它总是显示一个 0 诊所,它总是返回 false。如果您删除 beforeShowDay,它会起作用。我知道“return [true,''];”,如果我只有那个,它就可以工作。但是,无法弄清楚为什么它没有正确选择诊所来显示允许的日期。
请帮忙!