You need to sign in to do that
Don't have an account?

action.setcallback function not getting called automatically
Hi Devs,
To achieve a certain functionality , I have called a server side apex controller class which inturns calls batch class . I have written a code to hide spinner class inside action,setcallback funtion . This never gets executed untill I manually perform a button click anywhere on the screen or switch tabs / brower window .
Because of this ,the spinner keeps spinning and never goes off the screen until I manually click anywhere in window or switch tabs,after which the action.setcallback funtion get called (Verified in console tab) .
Is this happening because of batch class . How can I overcome this ?
To achieve a certain functionality , I have called a server side apex controller class which inturns calls batch class . I have written a code to hide spinner class inside action,setcallback funtion . This never gets executed untill I manually perform a button click anywhere on the screen or switch tabs / brower window .
Because of this ,the spinner keeps spinning and never goes off the screen until I manually click anywhere in window or switch tabs,after which the action.setcallback funtion get called (Verified in console tab) .
Is this happening because of batch class . How can I overcome this ?
So here is how i solve my issue.
I used $A.getCallback method with window.Timeout wrapping $A.getCallback.
Add below code in your method.
window.setTimeout(
$A.getCallback(function() {
if(flag==true)
cmp.set("v.Spinner",false);
else
{
cmp.set("v.Spinner",false);
cmp.set("v.Spinner",true);
}
}), 1000
);
Means after everysecond getCallback method will be called and if flag is true, spinner will be set to false, otherwise we just change the state of spinner and change back again. so that the component stay in scope.
flag here is boolean, and I am setting it to true when $A.setCallback function called.
Please flag this answer as best, if you are able to resolve this issue.