0

Trying to add Global Navigation is the list of navigation links, On click of link want to get the name/ id for the selected list.

I'm getting undefined, Can you please help me on this.

selectedValues(event) { // alert(event.detail.label); // alert(event.target.dataset.id); // alert(event.target.value); alert(event.target.dataset.menuItemId); alert(event.target.name); } 
<nav class="slds-context-bar__secondary" role="navigation" onclick={selectedValues}> <ul class="slds-grid"> <li class="slds-context-bar__item" data-menu-item-id="Dashboard" data-id="Dashboard"> <a href="javascript:void(0);" class="slds-context-bar__label-action" title="Dashboard" name="Dashboard" data-id="Dashboard" label="Dashboard"> <span class="slds-truncate" title="Dashboard">Dashboard</span> </a> </li> <li class="slds-context-bar__item "> <a href="javascript:void(0);" class="slds-context-bar__label-action" title="Timesheet" name="Timesheet" label="Timesheet"> <span class="slds-truncate" title="Timesheet">Timesheet</span> </a> </li> <li class="slds-context-bar__item "> <a href="javascript:void(0);" class="slds-context-bar__label-action" title="Invoices" name="Invoices" label="Invoices"> <span class="slds-truncate" title="Invoices">Invoices</span> </a> </li> </ul> </nav> 

1 Answer 1

1
onDashboardClick(event) { const dashboard = event.currentTarget.getAttribute("data-id"); } 
 <nav class="slds-context-bar__secondary" role="navigation" > <ul class="slds-grid"> <li class="slds-context-bar__item" data-menu-item-id="Dashboard" data-id="Dashboard" onclick={onDashboardClick}> <a href="javascript:void(0);" class="slds-context-bar__label-action" title="Dashboard" name="Dashboard" data-id="Dashboard" label="Dashboard"> <span class="slds-truncate" title="Dashboard">Dashboard</span> </a> </li> </ul> </nav> 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.