title: Calling datepicker options function from inside another function
body: <p>I have the following function that is using a promise to return data from asynchronous ajax call:</p>
  
  <pre><code>$("#mySelect").on('change', function() {
        var mySelectValue = $('#mySelect').val();
        var promise = getAvailableDates(mySelectValue);
  
        promise.done( function(data) { // tested and returning data
  
          var array = data;
  
          $('#a_date').datepicker({ // this function not working
             dateFormat: "yy-mm-dd",
             beforeShowDay: function (date) {      
                 var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
                 return [array.indexOf(string) &gt;= 0 ]
             }
          });
  
        });
     });
  </code></pre>
  
  <p>Why the <code>$('#a_date').datepicker()</code> function doesn't work inside another function?</p>
  
  <p>It doesn't respond to my <code>dateFormat</code> and <code>beforeShowDay</code> settings based on data returned from my Ajax call. </p>
  
  <p>How can I adjust Datepicker settings from inside a returned promise?</p>