0

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.