eve_mf
eve_mf

Reputation: 825

jQuery UI Datepicker - return values

I am following a tutorial about jQuery UI, and, although it works, I am trying to find the explanation in the jquery UI Datepicker documentation but I can't find what I am looking for.

To disable weekends, the tutorial creates a function:

   function onBeforeShowDay(theDate) {
        //day 0 is sunday, 6 is saturday
        if(theDate.getDay() == 0 || theDate.getDay() == 6) {
            return [false, "weekend", "Weekends disabled"];
        }
        return [true, ""];
    }

And then it gets called on beforeShowDay:

 $("#datepick1").datepicker({
           firstDay: 1,
           showButtonPanel: true,
           currentText: "Today",
           closeText: "close",
           beforeShowDay: onBeforeShowDay,
           numberOfMonths: 1,
           constrainInput: true

       });

The return value is an array with true/false, a css class you might want (it can be empty), and the title you want for those weekends. Where am I suppose to find this?

Thank you

Upvotes: 0

Views: 991

Answers (1)

Theodore K.
Theodore K.

Reputation: 5176

According to the API (http://api.jqueryui.com/datepicker/#option-beforeShowDay)

beforeShowDay

A function that takes a date as a parameter and must return an array with:

  • [0]: true/false indicating whether or not this date is selectable
  • [1]: a CSS class name to add to the date's cell or "" for the default presentation
  • [2]: an optional popup tooltip for this date

The function is called for each day in the datepicker before it is displayed.

Upvotes: 1

Related Questions