I'm implementing the vue-hotel-datepicker library into my project and I wish to dynamically add dates to the disabledDates property after making an ajax call, but my implementation does not seem to work. When I debug using the Vue devtools, I can clearly see that the disabledDates array contains my correct dates, it just does not render them as 'disabled'. It works when I hardcode those dates.
Template:
<datepicker
:disabledDates="disabledDates"
:firstDayOfWeek="1"
>
</datepicker>
JS:
data() {
return {
disabledDates: this.fetchBookedDates() //contains correct data, see screenshot below
}
},
methods: {
fetchBookedDates() {
window.fetch(Routing.generate('bookings'))
.then(response => response.json())
.then(data => this.disabledDates = data['period'])
.catch((error) => console.log(error));
}
}
Debugging steps:
The Vue devtools shows the disabledDates from my fetch call immediately upon page load, but all dates are still enabled on my datepicker:
Hardcoded (works):
When I hardcode a couple of dates, it does display my dates as 'disabled':
data() {
return {
disabledDates: ['2019-02-03', '2019-02-04']
}
}
And I get the same results in the Vue devtools as when I add them dynamically (also on page load):
What is wrong about my implementation and how should I fix this?
EDIT
The HotelDatePicker component is generated from my library, which contains the disabledDates property that I need to overwrite. This screenshot is the result from dynamically adding the disabledDates via an ajax call as explained above. After my ajax call, both components (Datepicker and HotelDatePicker) have the same disabledDates, containing the same data. But my dates are not rendered as being 'disabled' (only when I hardcode them)



disabledDatesare dynamic and to re-render them as disabled. Can you to a simplesetTimeoutfunction in your component which will update thedisabledDateswith hardcoded values to confirm this.