API
Air Datepicker has a convenient API that gives even more control over the component. The methods are accessed via a reference to the calendar instance:
let dp = new AirDatepicker('#el');
dp.show();
Methods
Shows calendar.
Hides calendar.
Goes to the next month/year/decade.
Goes to the prev month/hear/decade.
Selects one or several dates if array is passed
Date | string | numberDate format, or a string in ISO format, or a time in milliseconds. If a string or number cannot be converted to a date, this value will be ignored.booleantrue, the time from the passed date will be set to the value of the timepicker. By default, false - when selecting a date, the current time is set.Unselected passed date
Date | string | numberClears all selected dates.
Formats date in passed format.
Date | string | numberstringdateFormat option. You could see available tokens in documentation sectionDestroys calendar instance. Remove itself from DOM tree and all events from target element.
Updates calendar options. Using this method, you can set new values for the minimum or maximum dates, change the calendar language, etc.
objectbooleantrue then onSelect and onChangeView callbacks won't be triggeredSets the new value of the calendar view.
"days" | "months" | "years"booleantrue, then onChangeView won't be triggeredSets a new date for displaying the calendar. It is used when, for example, you need to show some other month without having to select a date.
Date | string | numberSets the focus to the cell with the passed date.
Date | string | numberbooleantrue and the new date is outside the current view date, the new view date will be set.Switch to the next view type. The view options are in order from days -> months -> years.
Date | string | numberSwitching to the previous view type.
Date | string | number(days|months|years) => Date[]Returns all dates that should be currently displayed in calendar.
((date: Date|string|number|Array<Date|string|number>)) => voidDisables one or multiple dates.
((date: Date|string|number|Array<Date|string|number>)) => voidEnables dates previously disabled.
Properties
HTMLDivElementDOM element of the calendar.
HTMLInputElementDOM element on which calendar was initialized. Type of the element depends on generic value, which can be passed with initialization. By default it is HTMLInputElement.
DateCurrent view date.
"days" | "months" | "years"Current view of the calendar.
Date[]An array of selected dates.
Date | falseA focused date.
booleanIs calendar visible.
Set<string>Set of disabled dates
booleanIf true then calendar has been destroyed with destroy() method