Subscribe to Events

Use the <component>.on(event, event_handler) method for a component to create a listener and subscribe to an event.

Each listener takes two arguments:

The following code example shows how to subscribe to the afterOptionSelection event for the PDP and then log the result to the browser console:

          var pdp = container.getComponent('PDP');

// ...

pdp.on('afterOptionSelection', function(event) {
  console.log('option ' + event.optionCartId + ' was selected with value ' + event.value)
}); 

        

Related Topics

Work with Events in an Extension
Cancel the Operation for an Event

General Notices