Newer Version Available
Dynamically Adding Event Handlers
This sample code adds an event handler to instances of c:sampleComponent.
You can also add an event handler to a component that is created dynamically in the callback function of $A.createComponent(). For more information, see Dynamically Creating Components.
addHandler() adds an event handler to a component.
Note that you can’t force a component to start firing events that it doesn't fire. c.someAction can be an action in a controller in the component's hierarchy. someAction and cmp refers to the event name and value provider respectively. someAction must match the name attribute value in the aura:registerEvent or aura:handler tag. Refer to the JavaScript API reference for a full list of methods and arguments.