Is there any way to pass additional data to a button-menu onselect
hander?
I have a lightning-button-menu in a loop (this is a minimal example, and not a real-world case). When a menu item is selected, then handleActionsMenuSelect
is called with a single event
argument. The event.detail.value
is set to the value
of the menu item selected, in this case either edit
or delete
.
But since the menu is in a loop, I also need to determine which item
to edit or delete. I tried putting item.id
in the menu's value
, but that does not appear in the event
data.
Is there any way i can also pass the associated item.id
to handleActionsMenuSelect
?
<template for:each={items} for:item="item">
<lightning-button-menu label="Actions" value={item.id} onselect={handleActionsMenuSelect}>
<lightning-menu-item label="Edit" value="edit"></lightning-menu-item>
<lightning-menu-item label="Delete" value="delete"></lightning-menu-item>
</lightning-button-menu>
</template>