[SalesForce] How to find which button in clicked in lightning

I'm creating a List that has one or more buttonIcons in the end.I'm creating these buttons dynamically with $A.createComponent.
While clicking the button,I need to find which button is clicked and then finding its position with getBoundingClientRect().
How can I do it?
I tried event.getSource(),event.currentTarget & event.target.
Nothing helped!
Or Is there any ways to find the position of a element in lightning.
(I need to show a popup relative to the button's position,can't use lightning:helptext)

Best Answer

  1. First find the body of the parent component of the dynamically created components.
  2. Then find the button and getBoundingClientRect Refer this QA,

`

findButton : function(cmp) {
        var parentElement = cmp.find("parent").get("v.body");
        console.log("child 1",parentElement[buttonIndex].find("buttonId").getBoundingClientRect());
    }

`

Related Topic