jQueryUI Datepicker noWeekendsAndHolidaysAndWeekDay
I've got this answer working but I'd like to extend it: jQuery UI Datepicker - Disable specific days
I'm stuck on adding this method to the solution:
beforeShowDay: function(date){
var day = date.getDay();
return [(day != 5)];
}
to noWeekendsAndHolidays. How can I add that in?
So, the datepicker beforeShowDay option would have 3 "false" returns:
- no weekends
- no holidays
- no selected weekday ("we're closed on Fridays, too")
working code with the first two options (I need help with the third):
$(document).ready(function(){
$("#datepicker").datepicker({
noWeekends: true,
numberOfMonths: 2,
beforeShowDay: noWeekendsOrHolidays,
minDate: '-1M -1W -1D',
maxDate: '+1M',
firstDay: 1
});
function nationalDays(date){
var natDays = [[7, 26, 'Shop-Closed']];
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;
}
}
});
Thank you in advance.
Like this?
function noWeekendsOrHolidays(date){
var noWeekend = $.datepicker.noWeekends(date);
if (noWeekend[0]) {
var isNotFriday = noFridays(date);
if (isNotFriday[0]) {
return nationalDays(date);
}
else {
return isNotFriday;
}
}
else {
return noWeekend;
}
}
function noFridays(date) {
var day = date.getDay();
return [(day != 5),""];
}
精彩评论