Newer Version Available
ui:menuSelect
For example, the ui:menuList component
registers this event so it can be fired by the
component.
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<aura:registerEvent name="menuSelect" type="ui:menuSelect"
18 description="The event fired when a menu item is selected." />
19You
can handle this event in a ui:menuList
component instance. This example shows a menu component with two list items. It
handles the ui:menuSelect event and click
events.
1<ui:menu>
2 <ui:menuTriggerLink aura:id="trigger" label="Contacts"/>
3 <ui:menuList class="actionMenu" aura:id="actionMenu" menuSelect="{!c.selected}">
4 <ui:actionMenuItem aura:id="item1" label="All Contacts" click="{!c.doSomething}"/>
5 <ui:actionMenuItem aura:id="item2" label="All Primary" click="{!c.doSomething}"/>
6 </ui:menuList>
7</ui:menu>When a menu item is clicked, the click event is handled before the ui:menuSelect event, which corresponds to doSomething and selected client-side controllers in the following example.
1({
2 selected : function(component, event, helper) {
3 var selected = event.getParam("selectedItem");
4
5 // returns label of selected item
6 var selectedLabel = selected.get("v.label");
7 },
8
9 doSomething : function(component, event, helper) {
10 console.log("do something");
11 }
12})| Attribute Name | Type | Description |
|---|---|---|
| selectedItem | Component[] | The menu item which is selected |
| hideMenu | Boolean | Hides menu if set to true |
| deselectSiblings | Boolean | Deselects the siblings of the currently selected menu item |
| focusTrigger | Boolean | Sets focus to the ui:menuTrigger component |