0

I am using lightningmenu item in an aura iteration

event.detail.menuItem.get("v.value");

Compoennt Code

 <lightning:buttonMenu iconName="utility:down" onselect="{!c.onButtonMenuSelect}" alternativeText="Show menu" class="{!financialAccountRecord.Id}">
                        <lightning:menuItem value="edit" label="Edit"/>

Controller Code:

   onButtonMenuSelect: function(component, event, helper) {
    var idx = event.detail.menuItem("value"));
    switch (event.getParam("value")){
        case "edit": helper.doEdit(); break;
        case "delete": helper.doDelete(); break;
    }
}

Howvere the value of idx is coming as undefined. I also tried the following variations:

({
  handleSelect: function(component, event, helper) {
    switch event.get("value") {
      case "edit": helper.doEdit(); break;
      case "edit": helper.doDelete(); break;
    }
  }
})
0

First use event.getSource() to get the menu component, then .get("v.value") to get the current menu item that was selected.

Try this for the controller code:

onButtonMenuSelect: function(component, event, helper) {
    switch (event.getSource().get("v.value")){
        case "edit": helper.doEdit(); break;
        case "delete": helper.doDelete(); break;
    }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.