Skip to main content

api.on()

Description

Allows attaching a handler to the inner events

Usage

api.on(
event: string,
handler: function,
config?: { tag?: number | string }
): void;

Parameters

  • event - (required) an event to be fired
  • handler - (required) a handler to be attached (the handler arguments will depend on the event to be fired)
  • config - (optional) an object with extra settings for the handler:
    • tag - (optional) a tag that identifies the handler so it can be removed later via the api.detach() method
info

The full list of the Booking internal events can be found here. Use the api.on() method if you want to listen to the actions without modifying them. To make changes to the actions, apply the api.intercept() method.

Example

// create Booking
const widget = new booking.Booking("#root", {
data,
// other configuration parameters
});

// output the selected slot id and time
widget.api.on("select-slot", (obj) => {
console.log("The selected slot", obj.id, "and time", obj.time);
});