0
我目前正在研究一个函数,该函数应该在jQuery datepicker中禁用周末和节假日。
我的功能看起来像这样
function calendarDateDisabled(date) {
//disable saturday (6) and sunday (0)
dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
if (date.getDay() == 6 || date.getDay() == 0 || ($.inArray(dmy, unavailableDates) == -1)) {
return true;
} else {
return false;
}
}
的错误是$ .inArray。控制台说Uncaught TypeError: Cannot read property 'inArray' of undefined
。
的VAR unavailableDates是这样var unavailableDates = ["1-5-2015", "25-12-2014","12-12-2014"];
功能的功能上面定义实现这样
disabled: function(date) {
return calendarDateDisabled(date);
}
任何人有一个想法有什么不对?
*编辑:的($.inArray(dmy, unavailableDates == -1)
到($.inArray(dmy, unavailableDates) == -1)
是的,你是对的。这是正确的语法,我现在编辑它。问题仍然存在。代码中是否还有其他问题? –
@Yannic'unavailableDates'可能超出范围,并确保'date'是日期对象而不是日期字符串 – charlietfl
非常感谢!这也是一个错误。最后,我通过重新实现jQuery UI来解决问题。奇怪的错误。坦克虽然你的帮助! –