I have a cmp with List of objects and iteration:

<aura:iteration items="{!v.Objects}" var="object">
    <div label="Set Id" name="{!object.Id}" onclick="{!c.action}">

Now by clicking "Set Id" I need to set the Id of that concrete object to my event. Now I set and get [event.getSource is not a function]:

var cmpEvt = component.getEvent("cmpEvt");
var objId =  event.getSource().get("v.name");
cmpEvt.setParams({"id" : "object.Id"});

How can I fix it?



 <div label="Set Id" data-record="{!object.Id}" onclick="{!c.action}">


  action : function(cmp,evt){
   var objId =  evt.currentTarget.dataset.record;
    var cmpEvt = cmp.getEvent("cmpEvt");
    cmpEvt.setParams({"id" : objId });
  • Thank you. But... Hmm. [event.getSource is not a function] Can it be because of list and iteration? Jun 26 '19 at 14:37
  • can you updated your question with actual error code? so that it's easy to reproduce the issue
    – sdandamud1
    Jun 26 '19 at 16:06
  • 1
    Please upvote if solution works for you for help others
    – sdandamud1
    Jun 26 '19 at 17:02
  • Sorry for the misinformation. I recently changed the button to div. Everything works with the button, but not with div. Jun 26 '19 at 17:04
  • for div you have to use datasets , edited my answer based on your comments.
    – sdandamud1
    Jun 26 '19 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.