0

I am using ondblclick event in html div tag and in controllerside am trying to get the id of the clicked event but it giving error,Below is sample code

component.cmp

<div id="{!Opp.Id + '__Budget'}" ondblclick="{!c.editBudget}">
    <ui:outputCurrency value="{!Opp.Budget__c/1000}" format="$#,##0k"/>
</div>

controller.js

editBudget : function(component, event, helper) {
    var whichOne = event.getSource();
} 

2 Answers 2

4

You need to do like below:-

editBudget : function(component, event, helper) {
    var whichOne = event.target.id;
}

event.target.id gives you the id defined in the div. Basically, For events fired by standard HTML elements, you can use event.currentTarget and event.target. For events fired by base Lightning components, use event.getSource() instead.

Read here:- Event Handling in Base Lightning Components

0

could you please try this one . might be this one helpful for you

editBudget : function(component, event, helper) {
    var whichOne = event.getSource().getLocalId();
}
1
  • I am getting error event.getSource() is not an function Apr 21, 2020 at 6:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .