Button that works only in Preview, why?

Hi, with the new version of the WIX platform, this function, sometimes, does not works on line ( in Preview it’s all ok ), has never been a problem before.

I am very worried because i t’s a very important function in my site, which updates all the DB,

What is happening?

Thanks
Claudio

export function button20_click(event, $w) {
 
    setTimeout(button8_click(event, $w), 100);
    setTimeout(button19_click(event, $w), 100);
    setTimeout(button9_click(event, $w), 100);
    setTimeout(button10_click(event, $w), 100);
    setTimeout(button18_click(event, $w), 100);             

    $w("#button20").collapse(); 

    $w("#input1").disable();
    $w("#input2").disable();

    $w("#group8").scrollTo();           
}

I don’t understand your code. Can you explain what you’re trying too do?

Hi @claudio-d-ambrosio , we need a context/more details.

Ok I’ll try…

button20_click ( event, $w ) function calls other buttons in sequence, each button saves to a single collection like for example button19_click(event,$w) that saves the collection linked to the dataset $w( #dataset9 ).

( A re single buttons because it is possible to click even one or two only for example … )

On line this function, like the other functions called, sometimes don’t work and I don’t understand why. in Preview it works well and has always been.

sorry for my bad english and thank you

export function button19_click(event, $w) {

 let gcasa = 0;
 let gfuori= 0;
 
 gcasa = parseInt($w("#input1").value, 10);
 gfuori = parseInt($w("#input2").value, 10);

 let goltotali = gcasa + gfuori;

 $w("#dataset9").setFieldValues({
 "golsegnati"    : $w("#table17").rows[0]['golsegnati']+goltotali}); 


 if (gcasa > gfuori)
 {
    $w("#dataset9").setFieldValues({
    "vintecasa" : $w("#table17").rows[0]['vintecasa']+1,
    "vintetot"   : $w("#table17").rows[0]['vintetot']+1
    });
 }
    $w("#dataset9").save();
    $w("#button19").label = 'OK';
}

I still don’t understand the code you posted earlier, but if you’re trying to save to data, the difference may be due to collection permissions. In preview mode you have an Admin permissions while on live site you’re maybe just a visitor or a regular member. So check the collection permissions.

The collection permessions are ok.
I don’t understand what has changed, I have not made any changes to the code or to the collections.

Also using the platform locally has become slow, sometimes when I click on the Database page on the left side to select a collection, it crashes and I have to exit the platform.

Another thing, this click on the editor page often doesn’t work for me, i need to close and reopen the editor. It didn’t happen before.

Hi Claudio,

I had the same issue - buttons were not working on live but were functioning on preview.

Please ignore the fact that I don’t know how to code - I use Dev Mode on wix and have coded on my site based on Youtube tutorials and a lot of trial and error.

I resolved the same issue after realising my code was correct, however had already entered ’ })’ about 30 lines earlier, then added more code and didn’t remove it from where I originally entered it.

After removing it and adding ‘})’ under my last line of code I’ve resolved the issue.

Apologies again for my lack of coding knowledge.

Thanks, I also solved it, I don’t remember how but I solved it :slight_smile: