I have an aura handler defined in the component:
<aura:attribute name="ErrorMessage" type="String" default=""/>
<aura:handler name="init" action="{!c.doinit}" value="{!this}"/>
Controller Class:
doinit : function(component, event, helper) {
var action = component.get("c.checkrecord");
action.setParams({
"primaryCampaignId": component.get("v.recordId")
});
action.setCallback(this,function(response){
var state = response.getState();
if(component.isValid() && state == "SUCCESS"){
var responseParse =response.getReturnValue();
if(responseParse != 'SUCCESS'){
var fordialog = component.find("searchBlock");
$A.util.toggleClass(fordialog, "toggle");
// $A.util.addClass(fordialog, 'slds-hide');
// $A.util.removeClass(fordialog, 'slds-show');
component.set("v.ErrorMessage", 'Please Add to this List');
}
else
console.log(responseParse);
}else{
console.log(state);
}
});
$A.enqueueAction(action);
},
There is a delay where the toggleclass fires, so basically, I can see something displayed and suddenly it gets hidden. When the component is being loaded, users are seeing some block which is disappearing because of the code condition statements.
I do have aura:waiting and done:waiting events, but still, the block shows for a second and disappear since I am hiding it based on the response. Can I use something to delay so the doinit finishes and then the user doesn't see the block or any kind of loading spinner?