Wix Blocks: Widget API Events

Wix Blocks is open to all Wix Studio users. To get access to Blocks, join Wix Studio.

Add an event when you want to provide information about actions that happen in the widget to the site owner. For example, when a customer adds a product to the cart. 

To add a new event:

  1. Click the Widget API  icon.
  2. Click Add New Public Event or hover over Events and click the  icon. 

3.  Name your event and provide a description. 

4. Fire the event from your widget code.

Use this syntax:

$widget.fireEvent('eventName', {eventObject}).

Define the condition for firing the evnet and, optionally, send event data. For example:

Copy

5. You can catch your event from two places

  • From any site where your widget is installed.
  • From any widget of your app to which you added this widget as an inner widget.

Note: Don't Forget to Document

Make sure to document your widget API by describing any property, event or function you add to it. These descriptions are available to site creators who install your widget.

Did this help?