0
votes

I have a collection of dates that I will use to instanciate my jquery datepicker widget. I have used beforeShowDay method to add a highlight css class to show on what days events are. The issue I encounter is that the css class is reset when I click on a date. Am I doing something wrong ?

Thanks

$("#datepicker").datepicker({
    inline: true,
    showOtherMonths: true,
    showButtonPanel: false,
    beforeShowDay: function(date) {
        var result = [true, '', null];
        var matching = $.grep(events, function(event) {
            return event.date.valueOf() === date.valueOf();
        });

        if (matching.length) {
            result = [true, 'highlight', null];
        }
        return result;
    },
    onSelect: function(dateText) {

    }
});
1
Can you reproduce it in a jsfiddle?Mario S

1 Answers

0
votes

Try this way, maybe you are not returning "true".

  beforeShowDay: function(dates) {
    for (i = 0, vetorLen = freedays.length; i < vetorLen; i++) {
        if ($.inArray(dates,freedays) != -1) {
            return [true, 'css-class-to-highlight', ''];
        } else {
            return [false, '', ''];
        }
    }
    return [true];
  },

hope this help you.