Switching month when setting disabled dates dynamically
See original GitHub issueExpected behaviour
I am making a calendar which loads disabled dates when changing months. Every time the month switch, an ajax request is sent for the previous month, the current month and the next month. Nothing should change on the calendar except of the disabled days.
Actual behaviour
The disabled days are disabled correctly, but the month visible in the calendar jumps back to the defaultViewDate.
Example code
$('.appointment-datepicker').datepicker('setDatesDisabled', disabledDates);
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Boostrap datepicker, disabled dates dynamically each month
You can dynamically update disabled dates using setDatesDisabled and you can listen to view changes adding handler for changeMonth ...
Read more >Dynamically Disable Specific Dates in DatePicker at runtime
Hello, I need to dynamicall disable dates in a datepicker at runtime ... in the datapicker (change the mode from day selection -...
Read more >ReactJS Dynamically Disable From and To Days input=date
dynamicallydisabledates #reactjsBased on user selection dates from and to how to disable the dates dynamically in reactjs class component.
Read more >How to Change Date range Dynamically in jQuery UI Datepicker
1. Set relative dates · dateFormat – Set date format. · maxDate – Set max selection date. In the example, I set it...
Read more >Javascript Calendar Disabled values Example - Mobiscroll
Calendar - Disabled values · Exact dates - Passing exact values like: '2020-05-20' will disable/enable the specific day · Date ranges - Passing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I encountered the same issue needing to disable dates based on an AJAX request. I worked around the issue of the date reverting back by using a call to the internal private function
_setDate
right after the call tosetDatesDisabled
.First:
$('.datepicker-selector').datepicker('setDatesDisabled', datesToBeDisabled);
and then, secondly:
$('.datepicker-selector').datepicker('_setDate', dateParam, 'view');
where
dateParam
is a date within the currently viewed month.Not entirely sure if this does not cause any side effects.
@dhakan I’ve suggested to add a public api to get and set current view date in #1978. As far as I investigated there aren’t any side effects using internal
_setDate
function withview
as second parameter to update view date. If you encounter any issues please let me know cause I’m planing to use the same approach to implement this public api.