air-datepicker
air-datepicker copied to clipboard
Inital date from December of previous years not being selected on widget.
Hi, I think I've found a bug.
Setting an initial date from a previous year in December results in a date not displayed on the widget initially. You can navigate and see that is selected, but that's not happening when you open the widget.
Here is the GIF I've captured switching between dates. Every time I was saving changes, the page was refreshed.
https://drive.google.com/file/d/1CCy0Wb2JBcDgautaWWXTmk7Pr8OFKW6J/view?usp=sharing
By the way, thanks for updating the widget, currently I'm migrating from v2 to v3.
Hi! I'm happy to hear that you are using Air Datepicker since version 2 :blush:.
Actually what you are describing is happens unintentionally - this behaviour is designed for case when user is actually clicks on date. When using selectDate
programmatically or with options it should just select date without any transition to new date.
I think I'll improve this behavior, but currently you can use startDate
option with selectedDates
to achieve what you want.
For now I'm setting startDate and then using selectDate to get date selected and displayed on widget.
// curDate is the desired date to be selected
var myDatePicker = new AirDatepicker('.datepicker-here',
{
dateFormat: datepickerFormat,
maxDate: new Date(),
locale: localeDate,
startDate: curDate,
onSelect ({date, fd}) {
if(date){
var timeInMillis = date.getTime();
$("#edit_birth_date").val(timeInMillis);
$("#send_form_edit").removeAttr("disabled");
}
}
});
myDatePicker.selectDate(curDate);