Activity Forums Salesforce® Discussions How to retrieve name of the button that fired the event having buttons reusing the same onclick handler in Salesforce ?

  • How to retrieve name of the button that fired the event having buttons reusing the same onclick handler in Salesforce ?

     Parul updated 3 years ago 3 Members · 1 Post
  • Aman

    Member
    September 23, 2018 at 11:15 pm

    Let’s say you have several buttons that reuse the same onclick handler. How will you retrieve the name of the button that fired the event?

  • shariq

    Member
    September 23, 2018 at 11:15 pm

    Use event.getSource() in the client-side controller to get the button component that was clicked. Call

    getLocalId() to get the aura:id of the clicked button.

  • Parul

    Member
    September 23, 2018 at 11:43 pm

    To retrieve the name of the button that fired the event call getLocalId() to get the aura:id of the clicked button.

    $("button").click(function() {
    var fired_button = $(this).val();
    alert(fired_button);
    });

Viewing 1 - 3 of 3 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Popular Salesforce Infographics