Andrew
Andrew

Reputation: 7768

How to Highlight specific dates in the datepicker

How to Highlight in BOLD specific dates in the datepicker? I have the array with dates var datesArray = new Array(); I know that I need to use beforeShowDay: method, but I can't figure it out to make it work.

This is my function:

            $(function() {
                $( "#datepicker" ).datepicker({ 
                    dateFormat: 'yy-mm-dd', 
                    onSelect: function(dateText, inst) {                             
                        dateSelected(dateText, tid) // run my function on click
                    }                     
                });
            });

Upvotes: 0

Views: 1113

Answers (1)

jd_7
jd_7

Reputation: 1862

Yes you need to use beforeShowDay event, here is the test

   ...
   beforeShowDay: function(d_date){
        console.log(d_date);
        //Here compare your Date Array and the d_date
        var d_picker = new Date(d_date);
        var s_class_highligth = '';
        if($.inArray(d_picker.getDate(),a_date_array)>-1){
            s_class_highligth = 'my_cell_highligth';
        }

        return [true, s_class_highligth, 'this is optional tooltip'];
    }
    ...

Upvotes: 1

Related Questions