api.detach()
Description
Allows removing/detaching event handlers
Usage
api.detach(tag: number | string ): void;
Parameters
tag
- (required) the name of the action tag
Example
In the example below we add an object with the tag property to the api.on()
handler, and then we use the api.detach()
method to stop logging the open-filter
event.
const booking = new booking.Booking("#root", {
data,
//other configuration parameters
});
// add handler
if (booking.api) {
booking.api.on(
"select-slot",
({ id }) => {
console.log("Selected: " + id);
},
{ tag: "track" }
);
}
// detach handler
function stop() {
booking.api.detach("track");
}
const button = document.createElement("button");
button.addEventListener("click", stop);
button.textContent = "Stop logging";
document.body.appendChild(button);