The onSelect event handler fires when the switcher changes the current calendar view.
DayPilot.Switcher.onSelect(args)args.source (HTMLElement) - the trigger that was used to change the view (for example a button)
args.target (DayPilot.Calendar or DayPilot.Month) - the target view component
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 }
],
onSelect: (args) => {
console.log("Selected view:", args.target);
}
});
switcher.select("buttonWeek");