Newer Version Available

This content describes an older version of this product. View Latest

Which Button Was Pressed?

To find out which button was pressed in a component containing multiple buttons, use Component.getLocalId().

Let’s look at an example with multiple lightning:button components. Each button has a unique local ID, set by an aura:id attribute.

Use event.getSource() in the client-side controller to get the button component that was clicked. Call getLocalId() to get the aura:id of the clicked button.

In the client-side controller, you can use one of the following methods to find out which button was clicked.
  • event.getSource().getLocalId() returns the aura:id of the clicked button.
  • event.getSource().get("v.name") returns the name of the clicked button.