0

I am trying to get the attribute value of the element clicked in my javascript code but for some reason the value I am getting is undefined.

This is the code:

HTML:

<c:button buttonLabel="Skype" buttonClass="valmetSecondaryButton noMargin" id="I_WANT_THIS_VALUE" onclick="{!c.openSkype}"/>

JS:

console.log(event.currentTarget.id);

This is working on Internet Explorer, havent tested in Firefox, but not working in Chrome. Also just so you know I am using Lightening Component, Salesforce!

Mizlul
  • 1,972
  • 3
  • 35
  • 92
  • 1
    Something like this asked before: https://stackoverflow.com/questions/32456290/event-target-id-vs-event-currenttarget-id-vs-this-id Thanks – Kapil Yadav Jan 25 '18 at 09:50
  • @kapilyadav i tried that link, no success, could you show me with a code or smth how do I get fixed this, I understood that in my case i am applying event bubbling but I dont know how can I make such that when the button is clicked stop it there and return id attribute of this button! – Mizlul Jan 25 '18 at 13:32

1 Answers1

0

Problem solved:

<span id="{!v.teamMember.email}" onclick="{!c.openSkype}">
                        <c:button buttonLabel="Skype" buttonClass="valmetSecondaryButton noMargin"/>
</span>

Thanks you all for your interest on solving this!

This link helped me solve the problem: https://salesforce.stackexchange.com/questions/160830/lighting-component-get-html-button-id-in-controller-js-working-in-firefox-not

Event Bubbling

Mizlul
  • 1,972
  • 3
  • 35
  • 92