Calendar: Selecting Dates in Calendar

Date: October 3, 2006

Component: Calendar

Version: v0.11.3

Click to select all dates of current month.

Question: Can I write a function that will select all dates in the currently displayed calendar month?

Answer: Sure. Here's how:

Start with a simple Calendar instance, and set its MULTI_SELECT option to true:

Create an element on the page to handle a click, one which you wire to a function that selects all of the days for the currently displayed calendar month. Our goal is to use Calendar's select method to select a date range, represented as a string (e.g., "12/1/2005-12/31/2005"); we pass that string as an argument to select, then re-render. Having done that, our dates are then selected and the display of the Calendar reflects the change.

Here's the interesting part — the handler — with comments:

Eric Miraglia, Yahoo Presentation Platform Engineering

(c)2006-2007 Yahoo Inc.