Adding custom events to components dynamically

You can add custom events to the components dynamically by using the addEventHandler() method in the component object.

The syntax for a custom event is as follows:

addEventHandler(String event, Function handler, String phase, String includeFacets) 

The following provides a description for each of the parameters of the addEventHandler component method:

  • The first argument is the name of the event that triggers the handler. The <aura:registerEvent> tag in a component's markup declares the event that the component fires.
For a component event, set this argument to match the name attribute of the <aura:registerEvent> tag. For an application event, set this argument to match the event descriptor ...

Get Learning Salesforce Lightning Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.