Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>onSelect</code> does not behave like <code>beforeShowDay</code>. You cannot return an array with <code>[true/false, class, popup]</code>. Instead, you will have to apply the class manually in the function.</p> <p>I'm not sure exactly what you are trying to do, but I would rearrange your code a bit. I made a array with the gray dates, then a variable with the green date. I never change the array, but update the green date on click, and then call a <code>refresh</code> on the <code>datepicker</code>:</p> <pre><code>$(function () { var togo = [ '10/25/2013' ]; var redDates = [ '10/27/2013', '10/28/2013' ]; var grayDates = [ '10/24/2013', '10/25/2013', '10/26/2013' ]; var greenDate = '10/24/2013'; $("#datepicker").datepicker({ numberOfMonths: 2, selectMultiple: true, beforeShowDay: function (date) { var theday = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear(); return [true, greenDate == theday ? "specialDate" : ($.inArray(theday, redDates) &gt;= 0 ? "specialDate2" : ($.inArray(theday, grayDates) &gt;= 0 ? "specialDate1" : ""))]; }, onSelect: function (dateStr) { var date = new Date(dateStr); var theday = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear(); if ($.inArray(theday, grayDates) &gt;= 0) { greenDate = theday; } $('#datepicker').datepicker("refresh"); } }); }); </code></pre> <p>I wasn't sure what <code>togo</code> was for, but this should get you started.</p> <p>Demo: <a href="http://jsfiddle.net/xU47h/3/" rel="nofollow">http://jsfiddle.net/xU47h/3/</a></p>
 

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