Newer Version Available

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

Using the Action Type

An Aura.Action is a reference to an action in the framework. You can pass an Aura.Action around so the receiving component can execute the action in its client-side controller.

Use $A.enqueueAction() to add client-side or server-side controller actions to the queue of actions to be executed.

The Aura Note sample app uses Aura.Action in the listRow component.

listRow.cmp

1<aura:component extensible="true">
2    ...
3    <aura:attribute name="onclick" type="Aura.Action"/>
4    ...
5    <li onclick="{!v.onclick}">
6        ...
7    </li>
8</aura:component>

The onclick attribute has type="Aura.Action".

noteListRow.cmp

1<aura:component extends="auranote:listRow">
2    ...
3    <aura:set attribute="onclick" value="{!c.openNote}"/>
4    ...
5</aura:component>

The noteListRow component extends the listRow component and sets the value for the onclick attribute in listRow to {!c.openNote}, which is a reference to an action in the client-side controller for noteListRow.cmp. The action is executed when a user clicks the bullet associated with <li onclick="{!v.onclick}"> in listRow.