[SalesForce] How to pass data attributes via lightning ui components with locker service active

With the new migraine inducing locker service active, the getElement() function doesnt work, which in turn means you cant access child nodes within a lightning ui element.

In a situation where say an iterator is used to generate some picklist input fields, there is now no way to know which picklist field actually triggered an event, as you cannot dynamically attribute an id nor append data attributes.

Or is there ? Any ideas out there ?…

Best Answer

First and foremost not able to access child nodes with locker is a myth and not sure what made you think through those lines .

Lets say you have DOM element like below

<div aura:id="divId" id="myChart">
  <div class="new">
   <ul>
    <li> ..</li>
  </ul>
  </div>
</div>

You can trace through the DOM easily via below JS in your controller

init : function(component, event, helper) {
  var element = component.find("divId").getElement();
}
Related Topic