Opened 14 years ago

Closed 14 years ago

Last modified 13 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.

Attachments (2)

ui.datepicker.highlight.patch (3.2 KB) - added by mstepnicki 14 years ago.
Adds setHighlight method (proposal)
ui.datepicker.highlight_v2.patch (4.0 KB) - added by mstepnicki 14 years ago.

Download all attachments as: .zip

Change History (5)

Changed 14 years ago by mstepnicki

Adds setHighlight method (proposal)

comment:1 Changed 14 years ago by Jörn Zaefferer

Milestone: TBD1.8

Changed 14 years ago by mstepnicki

comment:2 Changed 14 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 14 years ago by kbwood

Resolution: wontfix
Status: newclosed

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.