Button Won't Click, Static Event Handler Issue?

Website was working last week.
Multi-State box has a button that when clicked is supposed to move to the next state, after it validates data against a collection.
If the code entered by the user is in the collection, and it hasn’t previously been marked as used, it will open State 2, which allows a download. I have the console logging some text to tell me that the button has been clicked.
Last week, when a button was clicked, this worked, and “validate button clicked” was printed to the console.
This week, when a button is clicked, nothing happens.
Just tried this in Microsoft Edge, and it is still working as expected, but Chrome has the problem as defined above.

code is here:

import wixData from ‘wix-data’ ;
$w . onReady (() => {
$w ( “#button11” ). onClick ( event => {
console . log ( “validate button clicked” );
wixData . query ( “TricycleCodes” )
. eq ( “title” , $w ( “#input1” ). value )
. find ()
. then ( r => {
console . log ( r , “items” );
if ( r . items . length > 0 ){
if ( r . items [ 0 ][ “used” ] === “No” ){
$w ( “#downloadBox” ). changeState ( “State2” );
let toSave = {
“_id” : r . items [ 0 ][ “_id” ],
“title” : r . items [ 0 ][ “title” ],
“used” : “yes”
};

wixData . save ( “TricycleCodes” , toSave )
. then ( ( results ) => {
let item = results ; //see item below
} )
. catch ( ( err ) => {
let errorMsg = err ;
} );
}

Don’t waste your time to debug your code, it seems like it is (was) an error on Wix side.
You wil find more posts about the problem with MSB (MultiStateBox) when you inspect the last 20-25-posts.

Thanks Velo-Ninja. I called Wix customer care yesterday. They were unable to help and have forwarded me to the velo team and ai am awaiting a response from them. In the meantime, I’m taking a lot of heat for the site being down. Does anyone know a work-aroumd this issue?

I am not using the MSB in most cases at all anymore.
I am generating my own MSB (multi-state-box) by using JS-Objects-Structure and basic elements, like a an ordinary BOX-element (container) and for example BUTTONS + INPUTS.

All the rest is done by CODE.

This way i am generating my own MSB-functionality, which will work everytime :grin:. And by the way, it has even more benefits.

Less elements on the page = faster working/loading speed.

You need an example ?

An example would be great.
B

Sure!!!

Ok, let’s say → an Wix-Out-Of-The-Box-Element (<—predefined-stuff), do not work anymore → For example like here in this example. We do not know whyever the MSB got buggy, but yes sometimes such things happens.

However, now your task is to generate your own MSB → Multi-State-Box.

So —> let’s go…

Let’s imagine our MSB as a TAB-SWITCH-VERSION…(you have several tabs)

What you can see here?
What ? —> A MSB ? ----> Nooooooooooooo :stuck_out_tongue_winking_eye:

What you can see here are the following elements…

  1. 5x-Buttons (custom)
  2. 1x RichText-Input-Box

That’s all ??? —> Yepp!!! That’s all !!!

And how it should work now? → Well, without the right → CODE <— nothing will work.

What’s could be the idea to be able to solve our task?

  1. We will need some code for our BUTTONS…like…
$w('#btn1').onClick(()=>{//console.log("LAST: ", lastSelection);
            curSelection = 0;
            TEXT[lastSelection] = $w('#rtbJobs').value;
            lastSelection=curSelection;
            $w('#txtTitleMSB').text = $w('#btn1').label;            
            resetButtonColors();
            $w('#btn1').style.backgroundColor = colorOn;    
            $w('#rtbJobs').value = TEXT[curSelection];      
        });

        $w('#btn2').onClick(()=>{//console.log("LAST: ", lastSelection);
            curSelection = 1;
            TEXT[lastSelection] = $w('#rtbJobs').value;
            lastSelection=curSelection;
            $w('#txtTitleMSB').text = $w('#btn2').label;            
            resetButtonColors();
            $w('#btn2').style.backgroundColor = colorOn;
            $w('#rtbJobs').value = TEXT[curSelection];
        });

        $w('#btn3').onClick(()=>{//console.log("LAST: ", lastSelection);
            curSelection = 2;
            TEXT[lastSelection] = $w('#rtbJobs').value;
            lastSelection=curSelection;
            $w('#txtTitleMSB').text = $w('#btn3').label;            
            resetButtonColors();
            $w('#btn3').style.backgroundColor = colorOn;
            $w('#rtbJobs').value = TEXT[curSelection];
        });

        $w('#btn4').onClick(()=>{//console.log("LAST: ", lastSelection);
            curSelection = 3;
            TEXT[lastSelection] = $w('#rtbJobs').value;
            lastSelection=curSelection;
            $w('#txtTitleMSB').text = $w('#btn4').label;            
            resetButtonColors();
            $w('#btn4').style.backgroundColor = colorOn;
            $w('#rtbJobs').value = TEXT[curSelection];
        });

        $w('#btn5').onClick(()=>{//console.log("LAST: ", lastSelection);
            curSelection = 4;
            TEXT[lastSelection] = $w('#rtbJobs').value;
            lastSelection=curSelection;
            $w('#txtTitleMSB').text = $w('#btn5').label;            
            resetButtonColors();
            $w('#btn5').style.backgroundColor = colorOn;
            $w('#rtbJobs').value = TEXT[curSelection];
        });

So reading this code, we understand —> that there are several variables…

  1. curSelection → Could be the current selection of a button, right?
    In this case the buttons represents the TAB-FUNCTION, right?
  2. And when we have a current selection, there could also be a previous-selection aswell. And if we take a closer look…VIOLA!!! —>
TEXT[lastSelection] <--- there it is, we found the second vriable.
  1. We also recognize all the buttons, but how ???
$w('#btn5') --> btn = BUTTON (box = Box(Container... and so on.
  1. What the hell could be —> rtb <— rtbJobs???:sweat_smile:
    Maybe —> Richtext-Box ??? → Of course it is a Richtext-Box, we can even see it on our images.

  2. Ok next one —> $w(‘#txtTitleMSB’) <— What’s this??? Where to find it on the shown pics ? ? ? ?

  3. What is —> resetButtonColors(); ???
    This must be a further function!!! → Oh yes it is —>

function resetButtonColors() {
    $w('#btn1').style.backgroundColor = colorOff;
    $w('#btn2').style.backgroundColor = colorOff;
    $w('#btn3').style.backgroundColor = colorOff;
    $w('#btn4').style.backgroundColor = colorOff;
    $w('#btn5').style.backgroundColor = colorOff;
}

What else do we need? ? ?

Of course everything starts here…

$w.onReady(()=>{ console.log("Page-Ready..."); });

So when you have done everything right…you will get something like…

let colorOn = "#E8921D";
let colorOff = "#F4CB93";
let TEXT = [];
let curSelection, lastSelection=0;

$w.onReady(()=>{console.log("Page-Ready...");
    $w('#btn1').style.backgroundColor = colorOn;
  
    $w('#btn1').onClick(()=>{curSelection = 0;
        TEXT[lastSelection] = $w('#rtbJobs').value;
        lastSelection=curSelection;
        $w('#txtTitleMSB').text = $w('#btn1').label;            
        resetButtonColors();
        $w('#btn1').style.backgroundColor = colorOn;    
        $w('#rtbJobs').value = TEXT[curSelection];      
    });

    $w('#btn2').onClick(()=>{curSelection = 1;
        TEXT[lastSelection] = $w('#rtbJobs').value;
        lastSelection=curSelection;
        $w('#txtTitleMSB').text = $w('#btn2').label;            
        resetButtonColors();
        $w('#btn2').style.backgroundColor = colorOn;
        $w('#rtbJobs').value = TEXT[curSelection];
    });

    $w('#btn3').onClick(()=>{curSelection = 2;
        TEXT[lastSelection] = $w('#rtbJobs').value;
        lastSelection=curSelection;
        $w('#txtTitleMSB').text = $w('#btn3').label;            
        resetButtonColors();
        $w('#btn3').style.backgroundColor = colorOn;
        $w('#rtbJobs').value = TEXT[curSelection];
    });

    $w('#btn4').onClick(()=>{curSelection = 3;
        TEXT[lastSelection] = $w('#rtbJobs').value;
        lastSelection=curSelection;
        $w('#txtTitleMSB').text = $w('#btn4').label;            
        resetButtonColors();
        $w('#btn4').style.backgroundColor = colorOn;
        $w('#rtbJobs').value = TEXT[curSelection];
    });

    $w('#btn5').onClick(()=>{curSelection = 4;
        TEXT[lastSelection] = $w('#rtbJobs').value;
        lastSelection=curSelection;
        $w('#txtTitleMSB').text = $w('#btn5').label;            
        resetButtonColors();
        $w('#btn5').style.backgroundColor = colorOn;
        $w('#rtbJobs').value = TEXT[curSelection];
    });
});//-----------------------

function resetButtonColors() {
    $w('#btn1').style.backgroundColor = colorOff;
    $w('#btn2').style.backgroundColor = colorOff;
    $w('#btn3').style.backgroundColor = colorOff;
    $w('#btn4').style.backgroundColor = colorOff;
    $w('#btn5').style.backgroundColor = colorOff;
}

function consoleLogData(params) {   
    console.log("CURRENT: ", curSelection);
    console.log(TEXT[0]);
    console.log(TEXT[1]);
    console.log(TEXT[2]);
    console.log(TEXT[3]);
    console.log(TEXT[4]);
}

That piece of code is tested and works, well → but still is not complete.
It is just a short example, to show you how to generate your own features and functions.

Try to recreate this example, all you need to know to get it done, you will find inside this post.

With some patience, interest and brain —> you will be able to get this working.
And if you put some more logical thoughts onto this little code-project, you maybe will be able to generate a great MSB-Workaround.

Now try to get this to work with your new KNOWLEDGE.

!!! Good luck and happy coding !!!

!!! May the CODING POWER be with you !!!