Newer Version Available
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
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<aura:component extensible="true">
18 ...
19 <aura:attribute name="onclick" type="Aura.Action"/>
20 ...
21 <li onclick="{!v.onclick}">
22 ...
23 </li>
24</aura:component>The onclick attribute has type="Aura.Action".
noteListRow.cmp
1swfobject.registerObject("clippy.codeblock-1", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<aura:component extends="auranote:listRow">
18 ...
19 <aura:set attribute="onclick" value="{!c.openNote}"/>
20 ...
21</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.