pickadate.js icon indicating copy to clipboard operation
pickadate.js copied to clipboard

ajax call with possible dates as an object

Open patrickjuuu opened this issue 6 years ago • 1 comments

Hi there,

I have an Object which comes from a Magento Controller with possible Dates for the Datepicker. I can loop through the object with an each() function but I can't access them to the Datepicker. I want to use the datepicker for picking a Date based on a shipping method which is chosen and the datepicker have to update with new dates given from the controller.

I tried e.g.

function setDatepicker(data) {
 $('#myinput').pickadate({
  disable: [
     true,
     $.each(data, function(index, value) {
       new Date(value)
     }
  ],
 });
}

and

function setDatepicker(data) {
  $('#myinput').pickadate({
   disable: [
     true,
     data
   ],
  )};
}

the Object looks like this: (90) ["2019,1,26", "2019,1,27", "2019,1,28", "2019,2,1", "2019,2,5", "2019,2,6", "2019,2,7", "2019,2,8", "2019,2,12", "2019,2,13", "2019,2,14"]

and when I loop trough it with an each function it look like this: 2019,1,26 2019,1,27 2019,1,28 2019,2,1 2019,2,5 2019,2,6 2019,2,7 2019,2,8 2019,2,12 2019,2,13 2019,2,14

Is there any possibility to update it like this?

patrickjuuu avatar Feb 25 '19 07:02 patrickjuuu

I think this is a general question as this is just an issue with the Date object and our API.

Can you provide a working codepen?

DanielRuf avatar Feb 28 '19 18:02 DanielRuf