Repeater preloader closing way before the information is actualised

Hello friends! So i got a preload box that opens in front of my repeater. THis way when a filter is applyed to the data, this box preload shows up saying it’s loading and hides when it finishes. It’s working, however the box closes way before the repeater really actualises its information. I am guessing my code wait for filter to load on the dataset, and not really on the repeater.

Is it possible to make the preload hide only after --the repeater itself-- is refreshed and all the new info are there?

Here follows the bit of my actual code that I use for preload:


$w("#BTspecN").onClick((event,) => { 
    $w("#loadingWarning").show(); //Show the warning preloading box on click of the button that also sets the filter on a hidden input field.
    $w("#MyDataset").onCurrentIndexChanged(()=>{ 
       $w("#loadingWarning").hide(); 
 })

Any help is verry appreciated!

nobody? please?:tired_face:

Where is the Code For Filter? You need to add .then function which allows .hide function only after dataset is updated as per filter applied.

Raaj thanks for your answer. That was just a bit of the code, because there is a lot going on in the whole thing. Here goes the “full” code:

$w.onReady(function () {    

$w("#BTspecN").onClick((event,) => { 
    $w("#columnStrip15").show();//reveals the column/repeater docs names and info    

//preloade bit
        $w("#loadingWarning").show(); 
        $w("#profCred").onCurrentIndexChanged(()=>{ //data
            $w("#loadingWarning").hide(); 
        
        })
//actions bit        
        $w("#secondInput").value = $w("#KEYTEXT").text; //#KEYTEXT value: insert on secret Input
        let searchValue = $w('#secondInput').value; //value here
            $w("#profCred").setFilter(wixData.filter().contains('especialidades', searchValue)) //filter 

            
        });
    });
})
 

I cleaned the code a bit since there are a bunch of other little things going on up and down, but I believe this is what covers the issue with the preloader. As you see I have added a filter, but not a .then since I thought “onCurrentIndexChanged” would already cover that it should go after idataset had updated. Could you please help me understando were and how should I put the .then and if should I erase something from the actual code so it does not conflict?

Code Suiting Your Need:-

Add On Key Insert Event (Its fast)

export function OnKeyInsert(event) {
$w ( “#loadingWarning” ). show ();
$w( “#dataset4” ).setFilter( wixData.filter()
. contains ( ‘especialidades’ , $w ( ‘#secondInput’ ) .value)
)
.then(() => {
$w ( “#loadingWarning” ). hide ();
});
}

You can also use the same code for your OnClick Event

Also, wanted to inform you that use always same presets in code. $w(‘#value’). Dont change and use “”

Also, no need to refresh a repeater.

Use $w(‘#dataset’).refresh(); in .then function.

Example:-
export function OnKeyInsert(event) {
$w ( " #loadingWarning " ). show ();
$w( " #dataset4 " ).setFilter( wixData.filter()
.contains( ‘especialidades’ , $w( ’ #secondInput ’ ).value)
)
.then(() => {
$w ( " #loadingWarning " ). hide ();
$w(‘#dataset’).refresh();
});
}

Oh, I see. I’m gonna try to use it and infrom here if it works! Really apreciated your help Raaj.

Also, I forgot to share before, but if you are interested to see what this is all about this is the [page and how its working by now:](page:
https://innovah.wixsite.com/website/especialidades

i)
[https://innovah.wixsite.com/website/especialidades](page:
https://innovah.wixsite.com/website/especialidades

i)

yep, you were right, .then() solved the problem nicely. learning every day XD. I really thank you frined :wink: