Flatpickr: Call onDayCreate after instantiating flatpickr

Created on 29 Dec 2017  路  1Comment  路  Source: flatpickr/flatpickr

Hi,

I created an Flatpicker instance by

var fp = $("#date").flatpickr({
    minDate: "today",
    locale: {
        firstDayOfWeek: 1
    },
});

and after performing an ajax call, I get a set of dates which I need to color conditionally, so how to call onDayCreate in the ajax success callback method?

I tried

fp.set('onDayCreate', function (dObj, dStr, fp, dayElem) {});

fp.onDayCreate = function (dObj, dStr, fp, dayElem) {};

none of the above method worked as expected. Please guide on how to call onDayCreate after instantiating flatpickr.

Thank You!

Most helpful comment

Hello,

Perhaps its not working because hooks are collected into an array.
Try this:

// once your data is loaded, do this
fp.config.onDayCreate = [
  function (dObj, dStr, fp, dayElem) { }
];
fp.redraw(); 

>All comments

Hello,

Perhaps its not working because hooks are collected into an array.
Try this:

// once your data is loaded, do this
fp.config.onDayCreate = [
  function (dObj, dStr, fp, dayElem) { }
];
fp.redraw(); 
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ThomHurks picture ThomHurks  路  15Comments

joseluisq picture joseluisq  路  14Comments

mgohin picture mgohin  路  14Comments

ohtanya picture ohtanya  路  15Comments

chmln picture chmln  路  28Comments