question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Switching month when setting disabled dates dynamically

See original GitHub issue

Expected 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:open
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
dhakancommented, Dec 7, 2016

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 to setDatesDisabled.

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.

4reactions
jelhancommented, Dec 7, 2016

@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 with view 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found