Newer Version Available
Working with Events in JavaScript
Events communicate data across components. Events can contain attributes with values set before the event is fired and read when the event is handled.
Fire an Event
Get an Event Name
To get the name of the event that’s fired:
Get an Event Parameter
To get an attribute that’s passed into an event:
Get Parameters on an Event
To get all attributes that are passed into an event:
event.getParams() returns an object containing all event parameters.
Get the Current Phase of an Event
To get the current phase of an event:
Get the Source Component
To get the component that fired the event:
To retrieve an attribute on the component that fired the event:
Pause the Event
To pause the fired event:
Prevent the Default Event Execution
For example, you can prevent a lightning:button component from submitting a form when it’s clicked.
Resume a Paused Event
To resume event handling for a paused event:
Set a Value for an Event Parameter
To set a value for an event parameter:
If the event has already been fired, setting a parameter value has no effect on the event.
Set Values for Event Parameters
To set values for parameters on an event:
If the event has already been fired, setting the parameter values has no effect on the event.
Stop Event Propagation
To prevent further propagation of an event:
You can stop event propagation in the capture or bubble phase only.