Skip to main content

api.intercept()

Description

Allows intercepting and preventing the inner events

Usage

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

Parameters

  • event - (required) an event to be fired
  • callback - (required) a callback to be performed (the callback arguments will depend on the event to be fired)
  • config - (optional) an object with extra settings for the callback:
    • tag - (optional) a tag that identifies the callback 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
});

// every time the filter-data event is triggered, slots will be shown only for the morning time
widget.api.intercept("filter-data", data => {
data.time = [{ from: 9, to: 12 }];
});