When I have a button inside a component inside a lightning:card either as a body element or an action, the onClick is never fired. If I move the lightning:button outside of the container, the event fires as expected. I've tried searching everywhere for how to handle this situation as I'm sure it's a scoping issue, but I can't find a solid answer.

Here's an example component:

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <lightning:card title="Program Enrollment" iconName="standard:marketing_actions">
        <aura:set attribute="actions">
            <lightning:button label="Request" onclick="{!v.requestHelp}" />
        <div class="slds-align_absolute-center" style="height: 5rem;">
            Nothing here to see!
    requestHelp : function() {
  • 1
    it will be onclick={!c.requestHelp} not 'v.requestHelp' – User6670 Nov 17 '19 at 19:11

It should be c.requestHelp not v.requestHelp

c. is used to call controller functions and v. is used to access attribute values

  • doh! thank you! – Benny Nov 17 '19 at 19:25

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.