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.
Declaration
DayPilot.Switcher.onChange(args)Parameters
args.start(DayPilot.Date) - start date of the new selectionargs.end(DayPilot.Date) - end date of the new selectionargs.day(DayPilot.Date) - the selected dayargs.target(DayPilot.Calendar or DayPilot.Month) - the target view componentargs.preventDefault()- cancels the default action (date change)
Example
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");See Also
Availability
Availability of this API item in DayPilot editions:
| Product | Lite | Pro |
|---|---|---|
| DayPilot for JavaScript |
DayPilot