Events
Subscribe to every event of a picker and watch the payloads. This page documents @pglejzer/datepicker-ui, the companion of timepicker-ui.
Event log
#picker.on(event, handler) subscribes and returns a function that unsubscribes. The demo subscribes to every event. Open the picker, pick a day, move between months and open the month and year menus. The log keeps the last 8 events, newest first.
navigate also fires when the picker opens, with source: "open", and after setValue(), setOptions() and goTo(), with source: "api". The Clear button emits clear when there is a value or a picked day to clear. switch:view fires when the picker switches between the calendar and the text fields, which a single picker can do in the modal.
- No events yet
Callbacks
#Each event has an on* option in the callbacks group that does the same without an instance.
new DatepickerUI("#date", {callbacks: {onConfirm: ({ value }) => console.log(value),onSelectDay: ({ value, selected }) => console.log(value.value, selected),onNavigate: ({ year, month, source }) => console.log(year, month, source),onClear: ({ previousValue }) => console.log(previousValue),},}).create();
Note
setValue() does not emit confirm. setOptions() emits update. clear() emits clear, not confirm.