Reputation: 3033
I have this snippet of code that limits date to select to only saturday.
$( ".arrival-date" ).datepicker('option','beforeShowDay',function(date){
var today = date.getDay();
var result = [(date.getDay() == 6),'',(today == 'Sat' ) ? '': 'Not saturday'];
return result;
});
I however want to reenable all days other times depending on the the selected location and this doesn't work.
$(".arrival-date").datepicker();
Upvotes: 1
Views: 33
Reputation: 337560
I want to re-enable all days other times depending on the the selected location
Given this requirement you can simply amend the logic to first check what location was selected. If that location allows all days return an empty string, otherwise let execution flow through to your current logic. Try this:
$(".arrival-date").datepicker('option', 'beforeShowDay', function(date) {
if ($('#yourLocationField').val() === 'Someplace')
return [true, ''];
var today = date.getDay();
var result = [(date.getDay() == 6), '', (today == 'Sat') ? '' : 'Not saturday'];
return result;
});
Upvotes: 2