The onChange event handler fires when the switcher detects a change of the selected date, before the actual date change is applied. You can call args.preventDefault() to cancel the default action.
DayPilot.Switcher.onChange(args)args.start (DayPilot.Date) - start date of the new selection
args.end (DayPilot.Date) - end date of the new selection
args.day (DayPilot.Date) - the selected day
args.target (DayPilot.Calendar or DayPilot.Month) - the target view component
args.preventDefault() - cancels the default action (date change)
const nav = new DayPilot.Navigator("nav", {
// ...
});
nav.init();
const day = new DayPilot.Calendar("dpDay", {
// ...
});
day.init();
const week = new DayPilot.Calendar("dpWeek", {
// ...
});
week.init();
const month = new DayPilot.Month("dpMonth", {
// ...
});
month.init();
const switcher = new DayPilot.Switcher({
triggers: [
{ id: "buttonDay", view: day },
{ id: "buttonWeek", view: week },
{ id: "buttonMonth", view: month }
],
navigator: nav,
onChange: (args) => {
console.log("New range:", args.start, args.end);
}
});
switcher.select("buttonWeek");