Wix and Velo newbie here. I have created an onClick event to expand/collapse a container box. The way I have it set up is the container box is collapsed. Pressing button 1 (which is in the header) causes the container to expand, and pressing button 2 collapses the container again. The two buttons are stacked on top of each other (in the header) so it functions as “one button” for the user.
The problem occurs on first load of my site (homepage). Pressing on the button does not expand the container box. However, if you go to another page and then try to click button 1 (my header is on each page), the container expands and collapses as it should be. And if you go back to the original homepage, the button will now work as it should.
Does anyone have an idea as to why one needs to go to a different page before this onClick event works properly? Here’s my code below:
export function oh1_click ( event ) {
$w ( ‘#officehoursbox’ ). expand ();
$w ( ‘#oh1’ ). collapse ()
$w ( ‘#oh2’ ). expand ()
}
$w ( ‘#oh2’ ). onClick (()=>{
$w ( ‘#officehoursbox’ ). collapse ()
$w ( ‘#oh2’ ). collapse ()
$w ( ‘#oh1’ ). expand ()
})