Home:ALL Converter>Calling datepicker options function from inside another function

Calling datepicker options function from inside another function

Ask Time:2017-04-12T20:26:02         Author:ignite-me

Json Formatter

I have the following function that is using a promise to return data from asynchronous ajax call:

$("#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) >= 0 ]
           }
        });

      });
   });

Why the $('#a_date').datepicker() function doesn't work inside another function?

It doesn't respond to my dateFormat and beforeShowDay settings based on data returned from my Ajax call.

How can I adjust Datepicker settings from inside a returned promise?

Author:ignite-me,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/43369498/calling-datepicker-options-function-from-inside-another-function
yy