0
votes

I have a JQuery UI Datepicker widget with a beforeShowDay that calls a highlightday function. The function takes a date, and a list of dates to highlight. If the date is in the list, it gives it the "event" class.

function highlightday(date, highdates) {
  for (var i = 0; i < highdates.length; i++) {
    if ($.datepicker.formatDate("yy-mm-dd", date) === highdates[i]) {
      return [true, 'event'];
    }
  }
  return [true, ''];
}

This works fine. The "event" dates are labeled correctly.

The list of dates, however, is fetched from a server and only for the selected month. So if the datepicker starts off in May, the fetchdates function requests dates with events in May, and that's assigned to var dates.

The problem is when the user picks a different month. I have onChangeMonthYear set up to call a changemonth function, which is simply

function changemonth(year, month) {
  this.dates = fetchdates(this.id, year + "-" + month);
}

The dates variable is updated correctly, but the new dates are not highlighted because beforeShowDay already called highlightday. refresh() does nothing.

1

1 Answers

0
votes

Turns out this was a mistake on my part. dates was not being updated correctly.