Search.../

fireEvent( )

Fires an event that is defined in the Widget API.

Description

The fireEvent() function fires a widget event, which can then be handled from outside the widget (by code in a parent widget or a site page). When using the widget's API, the event is named on<EventName>, for example, onAddedToCart.

Syntax

function fireEvent(eventName: string, data: Object): void

fireEvent Parameters

NAME
TYPE
DESCRIPTION
eventName
string

The name of te event to be fired.

data
Object

A data object that is passed to the event handler.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

Fire a widget event

Copy Code
1$w(`#button1`).onClick(() => {
2 $widget.fireEvent(`addedToCart`, {productId: product.id, customerId: customer.id})
3});