uxsolutions / bootstrap-datepicker

A datepicker for twitter bootstrap (@twbs)
Apache License 2.0
12.67k stars 6.06k forks source link

How to setDisabledDates when event "onshow" is fired? #2654

Open ancuriskey2000 opened 2 years ago

ancuriskey2000 commented 2 years ago

Expected behaviour

If I'm doing it correctly, the disabled dates should be rerendered.

Actual behaviour

"Uncaught TypeError: this.setDatesDisabled is not a function" error is shown on Chrome Console.

Datepicker version used

Datepicker for Bootstrap v1.9.0

Example code

$(self.template.querySelector('.datepicker')).datepicker({
            format: 'dd/mm/yyyy',
            startDate: new Date(),
            endDate: finalDate,
            datesDisabled: disabledDates,
            ignoreReadonly: true

        }).on('show', function (selected) {
            self.setDatesDisabled(['10/04/2022'])

        }).on('changeDate', function (selected) {
            self.selectedDate = selected.target.value;
            let dateval = self.selectedDate;
            const selectedEvent = new CustomEvent("datechange", {
                    detail: dateval
                });
            self.dispatchEvent(selectedEvent);
        });