jQuery UI Datepicker - 禁用特定日期
有没有(容易)的方式设置jQuery UI Datepicker以禁止选择具体的预定日期?
Is there any (easy) way to set the jQuery UI Datepicker to disallow selection of specific, predetermined days?
我能够得到这种方法但是,它会产生一个空的错误,阻止它在IE中显示。
I was able to get this approach working, however, it produces a null error which prevents it from displaying in IE.
'natDays [...]。0'是null或不是一个对象
'natDays[...].0' is null or not an object
提前感谢!
更新:如果我包含一些代码,可能有帮助吗?无论如何,大部分是从上述线程中直接得到的:
UPDATE: Might help if I included some code, right? Anyway, most of this was taken straight from the aforementioned thread:
natDays = [
[7, 23], [7, 24], [8, 13], [8, 14],
];
function nationalDays(date) {
for (i = 0; i < natDays.length; i++) {
if (date.getMonth() == natDays[i][0] - 1
&& date.getDate() == natDays[i][1]) {
return [false, natDays[i][2] + '_day'];
}
}
return [true, ''];
}
function noWeekendsOrHolidays(date) {
var noWeekend = $.datepicker.noWeekends(date);
if (noWeekend[0]) {
return nationalDays(date);
} else {
return noWeekend;
}
}
$(function() {
$("#datepicker").datepicker({
inline: true,
minDate: new Date(2009, 6, 6),
maxDate: new Date(2009, 7, 14),
numberOfMonths: 2,
hideIfNoPrevNext: true,
beforeShowDay: $.datepicker.noWeekends,
altField: '#alternate',
});
});
再次感谢
您是否尝试使用前面的'var'关键字正确声明natDays?
Have you tried declaring natDays properly with the 'var' keyword in front?
另外 - 您的natDays结尾有一个逗号定义。
Also - you have an extra comma at the end of your natDays definition.
natDays [i] [2]将无法正常工作,因为您的数组只包含2个项目 - 尝试只是''
natDays[i][2] won't work as your the arrays only have 2 items in them - try just ''
此外,您还需要正确设置您的beforeShowDay函数名称 - 看起来不像调用自定义函数
Additionally, you'll want to set your beforeShowDay function name correctly - doesn't look like it's even calling your custom function