Add class to specific days in Bootstrap Datetime picker after data receives from Ajax

Viewed 1097

I want to add active class for available dates in Bootstrap after client receives data from ajax. Calendar on page is not a picker. It always displays after popup.

Calendar

I tried to set datetime array and added class in "ShowBeforeDay" event. But it doesn't work.

var active_dates = ["21/8/2017", "25/8/2017"];
            console.log('main page');
            $('#div_datetime').datepicker(
                {
                    format: "dd/mm/yyyy",
                    beforeShowDay: function (date) {
                        console.log("da..tata..ta");
                        var d = date;
                        var curr_date = d.getDate();
                        var curr_month = d.getMonth() + 1; //Months are zero based
                        var curr_year = d.getFullYear();
                        var formattedDate = curr_date + "/" + curr_month + "/" + curr_year

                        if ($.inArray(formattedDate, active_dates) != -1) {
                            return {
                                classes: 'activeClass'
                            };
                        }
                        return;
                    }
                }
            );

How can I add class for specific days in Bootstrap Datetime after data receives from Ajax?

1 Answers
Related