0

I am trying to use lightning spinner when a button on a lightning component is pressed like below

Component

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global"  controller="updateCaseRecord">
    <aura:attribute name="updateCase" type="Case" default="{'sobjectType':'Case'}"/>
        <div class="slds-m-around_xx-large">
        <lightning:button variant="brand" label="Pass To CS" onclick="{!c.passCaseToCS}"  />
        <lightning:spinner aura:id="mySpinner" alternativeText="Processing.." title="Processing.." variant="brand" size="large" class="slds-hide"/>
    </div>    
</aura:component>

Controller

({
  passCaseToCS : function(c, e, h) {
        h.passCaseToCS_helper(c,e,h);
    }
    
})

Helper

passCaseToCS_helper : function(c,e,h) {
     var spinner = component.find("mySpinner");
     $A.util.removeClass(spinner, "slds-hide");
    var set_action1 = c.get("c.passCase");
    set_action1.setParams({caseId: c.get('v.recordId')});
    set_action1.setCallback(this, function(result)
    {
        if (result.getState() === 'SUCCESS')
            {
                $A.util.addClass(spinner, "slds-hide");
                var toastEvent = $A.get("e.force:showToast");
                toastEvent.setParams({
                    message: 'Case has been Passed Successfully!' ,
                    type: 'success',
                    mode: 'pester'
                });
                toastEvent.fire(); 
            }
        $A.get("e.force:refreshView").fire();
    });
    $A.enqueueAction(set_action1);       
}})

When the button is clicked I get the error like

enter image description here

Can anyone please tell what I am missing here

1 Answer 1

2

In your helper function you have define 'component' parameter as 'c'

passCaseToCS_helper :function(c,e,h) {...}

so you have to use

c.find("mySpinner"); //not component.find("mySpinner");

You must log in to answer this question.

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