Newer Version Available
ui:menuSelect
For example, the ui:menuList component
registers this event so it can be fired by the
component.
1<aura:registerEvent name="menuSelect" type="ui:menuSelect"
2 description="The event fired when a menu item is selected." />You 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"
5 click="{!c.doSomething}"/>
6 <ui:actionMenuItem aura:id="item2" label="All Primary"
7 click="{!c.doSomething}"/>
8 </ui:menuList>
9</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 |