DayPilot.Switcher.onChange

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

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

DayPilot.Switcher.onChanged

DayPilot.Switcher.onSelect

DayPilot.Switcher Class

Availability

Availability of this API item in DayPilot editions:

LitePro
DayPilot for JavaScript