Skip to main content

Event Hooks

info

All methods listed below can be used multiple times.

onOpen()#

Subscribes the provided callback to an event that gets triggered each time the calendar shows up.

const datepicker = MCDatepicker.create({
el: '#datepicker'
});
datepicker.onOpen(() => console.log('The Datepicker is openned'));



onClose()#

Subscribes the provided callback to an event that gets triggered when the calendar is closed.

const datepicker = MCDatepicker.create({
el: '#datepicker'
});
datepicker.onClose(() => console.log('The Datepicker is closed'));



onCancel()#

Subscribes the provided callback to an event that gets triggered when the calendar is closed by clicking the cancel button.

const datepicker = MCDatepicker.create({
el: '#datepicker'
});
datepicker.onCancel(() => console.log('The Datepicker is closed'));



onClear()#

Subscribes the provided callback to the calendar's clear event.

const datepicker = MCDatepicker.create({
el: '#datepicker'
});
datepicker.onClear(() => console.log('The clear event is triggered'));



onSelect()#

Subscribes the provided callback to an event that gets triggered when the calendar's OK button is clicked.

const datepicker = MCDatepicker.create({
el: '#datepicker'
});
datepicker.onSelect((date, formatedDate) => console.log('Selected date: ' + date));

callback props#

PropTypeRequired
dateObjectNo
formatedDateStringNo



onMonthChange()#

Subscribes the provided callback to an event that gets triggered when the month is changed.

const datepicker = MCDatepicker.create({
el: '#datepicker'
});
datepicker.onMonthChange(() => console.log('The month has been changed'));



onYearChange()#

Subscribes the provided callback to an event that gets triggered when the year is changed.

const datepicker = MCDatepicker.create({
el: '#datepicker'
});
datepicker.onYearChange(() => console.log('The year has been changed'));