0

I am using Pikaday datepicker. All works well but for some complicated date manipulation I need to add/remove multiple dates.

<code>
var start_date = new Pikaday({
    disableDayFn: function(date) {
        var enabled_dates = ["06/11/2019","06/17/2019","06/24/2019"]; // dates I want to enable.
        var disabled_dates = ["06/15/2019", "06/22/2019"]; // dates I want to disable.

        if ((date.getDay() === 1 || date.getDay() === 2 || ($.inArray(moment(date).format("MM/DD/YYYY"), disabled_dates) === 0)) && $.inArray(moment(date).format("MM/DD/YYYY"), enabled_dates) === -1) {
          return date;
        }
    },
    format: 'MM/DD/YYYY',
    field: document.getElementById('start_date'),
});
</code>

In this example above:

  1. [this works fine] I am using an enabled_dates array to enable multiple dates I need to display on calendar.

  2. [this works fine] I am removing ALL mondays and tuesdays using the actual day value '1' and '2' example: date.getDay() === x

  3. [not working] when I try pass multiple dates in an array the first date is removed but the subsequent dates are not actioned.

In this example all good except for the date "06/22/2019" not removed as appears only removes the first date in array not subsequent

Fiddle demo: http://jsfiddle.net/netfast/k36nhacz/18/

netfast
  • 1
  • 1

0 Answers0