title: Jquery UI datepicker - enable only array of dates returned from server
body: <p>I've gone through literally every post on this topic. It's not something new. Yet every time some one comes here with the same problem in different context. Seems like JQUERY UI should support this inherently in its next big release. Ok, now here is my code, where I want to enable only those dates in datepicker returned from a controller to my view, which I input in <code>&lt;input&gt;</code> hidden fields. Here is my html:</p>
  
  <pre><code>&lt;?php foreach ($trip_dates as $single_trip_date) { ?&gt;
  &lt;form id="datesetter"&gt;
  &lt;?php $date = new DateTime($single_trip_date-&gt;trip_date); ?&gt;
  &lt;input type="hidden" value="&lt;?= $date-&gt;format('d-m-Y'); ?&gt;"/&gt;
  </code></pre>
  
  <p></p>
  
     
  
  <p>and this is my code:</p>
  
  <pre><code>$(document).ready(function(){ 
  var date_d = [];
  $("#datesetter input[type=hidden]").each(function() {
  var date_d = new Date();
  date_d = [$(this).val()];
  console.log(date_d); // Output is: ["12-01-2016"] ["14-01-2016"]
  
  function addZ(n) {
  return (n &lt; 10? '0' : '') + n;
  }
  function available(date) {
  dmy = addZ(date.getDate()) + "-" + addZ((date.getMonth()+1)) + "-" + date.getFullYear();
          if ($.inArray(dmy, date_d) == -1) {
              console.log(dmy);
              console.log("php dates: "+date_d); //out put is only first date in series, i.e. 12-01-2016
          return [false, ""];
          }          else {
          return [true,"","Unavailable"];
          }
          }
  
   $('#datepick').datepicker({
      dateFormat: 'dd/mm//yy',
      beforeShowDay: available
  });
      });
  
  });
  </code></pre>
  
  <p>But when I see output in console.log for available dates in available function, it prints series of first date only repeatedly, there is no sign of another date, which is 14-01-2016.</p>
  
  <p>In result, only 12th date is enabled in datepicker, but all else disabled. I want all the dates in date_d variable to be enabled. can anybody tell me how to do it?</p>