I want to set the disabled days dynamically, depending on what was selected from a select-input. My option has the following data field:
data-disableddays="2,3,4,5"
I have an onchange event on my select. there I am getting the value of the data-disableddays:
var disableddays = $(this).find(':selected').data('disableddays');
The console.log output is correct (2,3,4,5)
When I am initializing the pickadate:
var picker = $('#tripstart').pickadate({
format: 'd.mm.yyyy',
min: new Date($mystart),
max: new Date($myend),
firstDay: 1,
disable: [
disableddays
]
});
Nothing is happening. Replacing the variable disableddays with "2,3,4,5" everything is working well. What do I have to do to make this variable working at this place?
Try doing this
var disableddays = $(this).find(':selected').data('disableddays');
disableddays = disableddays.split(',').map(day=>parseInt(day));
var picker = $('#tripstart').pickadate({
format: 'd.mm.yyyy',
min: new Date($mystart),
max: new Date($myend),
firstDay: 1,
disable: disableddays
});
Basically, disabledays should be an array of integers.