I hope you can help. I am trying to disable dates from a variable which is generated from a AJAX request. The result of the request is the dates which I am trying to disable. I have then removed the double quotes which I think should not be there:
var formattedDisabledDates = JSON.stringify(data_disable_dates.dates);
var formattedDisabledDates = formattedDisabledDates.replace(/['"]+/g, '');
The output in console log for formattedDisabledDates is as follows:
[[2019,12,25],[2019,12,26],[2020,01,01],[2020,04,10],[2020,04,13],[2020,05,08],[2020,05,25],[2020,08,31],[2020,12,25],[2020,12,26],[2020,12,27],[2020,12,28],[2021,01,01]]
If i paste that into here:
pickerPU.set('disable', #here#);
it works fine and all the dates are disabled correctly.
If I replace it with the variable:
pickerPU.set('disable', formattedDisabledDates);
I get an error back:
Uncaught TypeError: datesToDisable.map is not a function
this is from the picker.date.js file
The only way I can get in to work is using eval(formattedDisabledDates) but this is considered unsafe?
Hello
I hope you can help. I am trying to disable dates from a variable which is generated from a AJAX request. The result of the request is the dates which I am trying to disable. I have then removed the double quotes which I think should not be there:
var formattedDisabledDates = JSON.stringify(data_disable_dates.dates); var formattedDisabledDates = formattedDisabledDates.replace(/['"]+/g, '');
The output in console log for formattedDisabledDates is as follows: [[2019,12,25],[2019,12,26],[2020,01,01],[2020,04,10],[2020,04,13],[2020,05,08],[2020,05,25],[2020,08,31],[2020,12,25],[2020,12,26],[2020,12,27],[2020,12,28],[2021,01,01]]
If i paste that into here: pickerPU.set('disable', #here#); it works fine and all the dates are disabled correctly.
If I replace it with the variable: pickerPU.set('disable', formattedDisabledDates);
I get an error back: Uncaught TypeError: datesToDisable.map is not a function this is from the picker.date.js file
The only way I can get in to work is using eval(formattedDisabledDates) but this is considered unsafe?
What am I doing wrong, can anyone help?