function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC GuestSFDC Guest 

Lightning window timesetOut while displaying modal

Please let me know how to set timeout in lightning component controller. Thanks in advance.

     
Lightning javascript controller:

        openModel: function(component, event, helper) {
          var selectedItem = event.currentTarget;
           var index = selectedItem.dataset.record;
           var action = component.get("c.getRec");
           action.setParams({"caseValue": index});
           
           action.setCallback(this, function(response) {
                var state = response.getState();
               //alert(' data is:' + JSON.stringify(response.getReturnValue()));
                if (state === "SUCCESS") {
                    component.set("v.recObj", response.getReturnValue());
                }
                else {
                    console.log("Failed with state: " + state);
                }
            });
            $A.enqueueAction(action);
        
           // Set isModalOpen attribute to true
          component.set("v.isModalOpen", true);
           
          //find modal using aura id
        var modal = component.find("myModal");
        var modalBackdrop = component.find("myModal-Back");
    
       // Now add and remove class
        $A.util.addClass(modal, 'slds-fade-in-open');
        $A.util.addClass(modalBackdrop, 'slds-fade-in-open');
    }

 
ANUTEJANUTEJ (Salesforce Developers) 
Hi there,

Can you try checking the below link that has an implementation of callout that you could use for your scenario?

>> https://www.mhamzas.com/blog/2020/04/15/settimeout-in-lightning-component-aura/

Below is the code I found in the above link for quick reference:
window.setTimeout(
     $A.getCallback(function() {
          helper.hideSpinner(component, helper)
     }), 500
);

>> https://salesforce.stackexchange.com/questions/149870/how-to-add-waiting-time-in-lightning-component-controller

I hope this helps and in case if this comes handy can you please choose this as the best answer so that it can be used by others in the future.

Regards,
Anutej