Ticket #4528 (closed enhancement: wontfix)

Opened 5 years ago

Last modified 5 years ago

highlight specific dates in datepicker

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

Description

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

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

Change History

Changed 5 years ago by mstepnicki

Adds setHighlight method (proposal)

comment:1 Changed 5 years ago by joern.zaefferer

  • Milestone changed from TBD to 1.8

Changed 5 years ago by mstepnicki

comment:2 Changed 5 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.

Usage:

{{{ 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 5 years ago by kbwood

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

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.