Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#4528 closed enhancement (wontfix)

highlight specific dates in datepicker

Reported by: mstepnicki Owned by:
Priority: minor Milestone: 1.8
Component: ui.datepicker Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:


I have to highlight some specific dates on given datepicker. I quickly hacked together additional setHighlight method. It's my first attempt in modifying jQuery UI, so probably I've made a lot of mistakes. For example, i don't know if oc() function is at all necessary.

What I'd like to see is the more generic ability to set individual class for each cell - I couldn't achieve this yet, and the patch just fixes my specific problem. It's just a proposal and is probably not feasible to be merged directly.

Patch attached below.

Change History (3)

comment:1 Changed 8 years ago by jzaefferer

  • Milestone changed from TBD to 1.8

comment:2 Changed 8 years ago by mstepnicki

OK, so I've managed to implement it. I still don't know if oc() function is necessary, but the rest of the code seems well enough.


{{{ jQuery("#datepicker").datepicker('setHighlight', { css_class_name1: [Array of Dates],

css_class_name2: [Array of Dates]



Example: {{{ jQuery("#datepicker").datepicker('setHighlight', { blue: [new Date (2009,5,1), new Date(2009,5,2)],

red: [new Date (2009,5,7), new Date(2009,5,12)]



Of course css classes need to be defined somewhere in custom css file.

ui.datepicker.highlight_v2.patch attached.

comment:3 Changed 8 years ago by kbwood

  • Resolution set to wontfix
  • Status changed from new to closed

You can already achieve this through the beforeShowDay setting. This is set to a function that is called for each date shown. It receives the date and returns an array where [0] is true if the date is selectable, false if not, [1] is one or more CSS classes to apply, [2] is an optional popup tooltip. See the noWeekends function in the plugin for an example.

Note: See TracTickets for help on using tickets.