triggering a function before $("").datepicker()

I have a listeJNO variable that I need in beforeShowDay function


                format: "dd/mm/yyyy",
                weekStart: 1,
                maxViewMode: 3,
                language: "fr",
                calendarWeeks: true,
                beforeShowDay: function (date) {

                    for (var i = 0; i < listeJNO.length; i++) {
                        console.log(date >= listeJNO[i].Begin && date <= listeJNO[i].End);
                        if (date >= listeJNO[i].Begin && date <= listeJNO[i].End) {

                            return {

                                classes: 'morning-ferie'

but before, I need to define the listeJNO. I have a function which is doing this actually its getListeJNO(). So here’s my problem, wherever I put the getListeJNO() to initialize data in listeJNO, the beforeShowDay option inside the $('calendrier').datepicker({...}) always goes first where listeJNO has no data inside

110 thoughts on “triggering a function before $("").datepicker()”