0

I am trying to pass the value/id of record on clicking of button to contoller.js. But Iam not able to get the value in contoller. Any inputs how the value can be passed and retreived in controller.js. Below is the piece of code Iam using currently.

Piece of component code

{<ui:button aura:data-id="{!account.acc.ContentDocumentId}" buttonTitle="Release Lock" disabled="{!!account.acc.visu__Locked__c}"  class="button" label="Release Lock" press="{!c.Releaselock}"/>}

Controller.js*

 Releaselock : function (component, event, helper){     

       var id = event.target.getAttribute("data-id");
      alert(id);

  }

Thanks in Advance..

Br Visu

1

1 Answer 1

1

Why don't you put the id on the aura:id attribute and do event.getSource().getLocalId() ?

Component

<ui:button aura:id="{!account.acc.ContentDocumentId}" buttonTitle="Release Lock" disabled="{!!account.acc.visu__Locked__c}"  class="button" label="Release Lock" press="{!c.Releaselock}"/>

Controller

Releaselock : function (component, event, helper){     
   var id = event.getSource().getLocalId();
   alert(id);
}
1
  • Edited my answer to include some code... Nov 15, 2016 at 15:24

You must log in to answer this question.

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