Skip to main content

HTML Events

Bike Matrix emits the following events which can be listened to:

EventBubblesComposedCancelableDescription
BM:InitializednononoAfter Bike Matrix SDK / Web Components have been initialized.
RefreshCompatibilityyesyesnoWhen the compatibility on a page requires refreshing.
BikeChangedyesyesnoWhen the selected bike has changed.
BikeChangingyesyesnoJust before bike has changed.
BmToggleModalyesyesnoToggle the Bike Selector visibility.

The following section provides additional detail for some events:

'BikeChanged' Detailed

A HTML 'BikeChanged' event will fire when the user selects or deselects a bike.

You can listen for this event, and then check the window.BikeMatrix.getCurrentBike() to see if it has a value or not (to determine selected/deselected). If there is a value, you can also use the 'name' parameter to get the Bike Name, and 'key' to get the Bike Matrix ID.

document.addEventListener("BikeChanged", () => {
const bike = window.BikeMatrix?.getCurrentBike();
console.log("[BikeChanged] new bike:", bike);
if (bike) {
console.log("[BikeChanged] Bike Matrix ID:", bike.key);
console.log("[BikeChanged] Bike Name:", bike.name);
}
});