0

I am trying to show a lightning spinner on search and disable it after the search has loaded. The method that calls the search is in a different file than the related html to show the spinner, which is the same file that handles the loaded results. I have tried importing the method into the file that handles the search, but this has only produced errors.

Here is the code for the file with the associated html

@track showSpinner = false;

    handleResult(event){
        console.log("Loaded");
        this.showSpinner = false;
        });
    }

    enableSpinner() {
        this.showSpinner = true;
    }

and here is the code for the file that handles the initial search:

export default (Base) => class LwcSearchParamMixin extends Base {
    @wire(MessageContext)
    messageContext;

    params = {};

    editParam(key, value){
        console.log("Searching");
        this.params[key] = value;
        publish(this.messageContext, searchParamUpdated, {
            id:key, value
        })
    }
}
4
  • Welcome to Salesforce Stack Exchange (SFSE)! Please edit your question to add the exact (copy/paste) text of the error(s) that you have received.
    – Moonpie
    Commented Nov 18, 2022 at 22:29
  • 1
    There's not enough code here to help, unfortunately. It's not clear how the base class and mixin are related, or how one is trying to call the other. The more details we have, the better we can help you.
    – sfdcfox
    Commented Nov 18, 2022 at 23:35
  • Sorry for the late response! The mixin file is called when the user performs a search. The html for different types of searches are in a few different files, but they all call the editParam() function, so all of the searches go through this point (which is why I thought to change the spinner bool there). The file that should be showing the spinner runs the handleResult() function when the search is completed, so I thought to update the spinner to false in this function. I run into the issue that when I try to access the showSpinner variable from the mixin, I can't pass by reference.
    – Kyle M
    Commented Nov 28, 2022 at 18:26
  • I actually have found a solution to this issue using a completely different approach that doesn't involve passing variables to different files (so no need to think through this issue)!
    – Kyle M
    Commented Nov 28, 2022 at 19:04

0

You must log in to answer this question.

Browse other questions tagged .