Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing beforeShowDay in JQuery UI Datepicker to close out days of the week
    text
    copied!<p>what I am trying to do is grey out some days of the week for a venue for when it is closed. Each venue might be closed on different days.</p> <p>I can use the following code as a test to close out all Sundays:</p> <pre><code>$('#bookingDatepicker').datepicker({ minDate: 0, maxDate: '+3M', dateFormat: 'DD, d MM, yy', altField: '#actualDate', altFormat: 'yy-mm-dd', beforeShowDay: closedDays }); function closedDays(date) { if (date.getDay() == 0){ return [false,"","Venue Closed"]; } else { return [true, ""]; } } </code></pre> <p>However I might have to close out more than one day and they might not run next to each other. In my code from the database I can create a string, examples below, which show what days are open...</p> <pre><code>1,2,3,4,5,6,0 //I would want to show no days closed 2,3,4,5,6 //I would want to show Sunday (0) and Monday (1) closed </code></pre> <p>I am not sure what to do with this though to get the code above to work. I am using PHP to create the string so can manipulate it using that if need be.</p> <p><strong>EDIT</strong></p> <p>As is usual when you post a question you get a minor breakthrough! I have developed the code below, it works if I use the dummy data in it, however I need find a way of wrapping my string values in "". That is now causing me trouble, if I just use var cloDays = [2,3,4,5] it ceases to work</p> <pre><code>var cloDays = ["2","3","4","5"]; function closedDays(date){ var sDate = date.getDay().toString(); if ($.inArray(sDate, cloDays) == -1) return [false,"","Venue Closed"]; else return [true, ""]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload