Probably something simple I’m missing here, but I’ve added some basic code to hide the menu and make a button clickable. Works no problem in preview but neither are working on the published live pages.
Any suggestions on why this wouldn’t be working on live?
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
export function button2_click(event) {
let value = $w( ‘#tourbookingtool2’ ).collapsed
if ( value === true ) {
$w( ‘#tourbookingtool2’ ).expand()
}
else {
$w( ‘#tourbookingtool2’ ).collapse()
}
}
$w( ‘#horizontalMenu2’ ).hide();
import wixWindow from ‘wix-window’ ;
Edit: solved! New code is:
import wixWindow from ‘wix-window’ ;
$w.onReady( function () {
$w( ‘#horizontalMenu2’ ).hide();
});
export function button2_click(event) {
if ($w( ‘#tourbookingtool2’ ).collapsed){
$w( ‘#tourbookingtool2’ ).expand();
} else {
$w( ‘#tourbookingtool2’ ).collapse();
}
}
Hello Rebecca,
first time coding?
Try this…
import wixWindow from 'wix-window';
export function button2_click(event) {
let value = $w('#tourbookingtool2').collapsed
if( value === true) {
$w('#tourbookingtool2').expand()
}
else {
$w('#tourbookingtool2').collapse()
}
$w('#horizontalMenu2').hide();
}
Hi 
Did you publish your site after you made the changes? Send us your site URL so we can investigate.
I did!
This is the page I’m currently working on
https://www.magicmountainairdriedaycare (dot) com /adtourcareer
Very early days,
Tried this but now luck. Also the menu needs to be hidden all the time not as part of the button clicking function
To hide an element permanently you can do it like this…
Take a look at this very similar example, perhaps it will help you…
https://russian-dima.wixsite.com/meinewebsite/blank-8
Check also the connection between page and code.
You have errors for calling a function outside the page is ready, I think it should be inside the onClick() event handler.
This is the line (14):
$w('#horizontalMenu2').hide();
Replace your code with this and you’re good to go:
import wixWindow from 'wix-window';
export function button2_click(event) {
if ($w('#tourbookingtool2').collapsed){
$w('#tourbookingtool2').expand();
} else {
$w('#tourbookingtool2').collapse();
}
$w('#horizontalMenu2').hide();
}
Ahmad
Okay this is awesome and got the button working, thank you.
The menu being hidden isn’t intended to be related to the button click though. I just want that hidden entirely on that page. (I can’t just click hidden on load as that hides on every page. I just need it hidden on this landing page)
I tried just moving that line outside of the function but that not only doesn’t work, but also stops the button working too. If I delete that line entirely button works.
I really appreciate your help here
Thank you for the help, unfortunately this button hides the menu on every page. I just need it hidden on this page though
I guess I need to make a new function for on page load and put it in there?
You’re welcome Rebecca 
No you just need to put it inside the Page code section inside the page’s onReady() function, here’s how:
$w.onReady(() => {
$w('#horizontalMenu2').hide();
})
This will hide the menu only on this page.
If your problem is solved, mark this question as solved.
I got it!
Final code:
import wixWindow from ‘wix-window’ ;
$w.onReady( function () {
$w( ‘#horizontalMenu2’ ).hide();
});
export function button2_click(event) {
if ($w( ‘#tourbookingtool2’ ).collapsed){
$w( ‘#tourbookingtool2’ ).expand();
} else {
$w( ‘#tourbookingtool2’ ).collapse();
}
}
Thanks again for your help!
You’re welcome
Glad that I helped.
If you don’t have any further questions, please mark this question as answered.
Hover over the best answer and click on the “Mark as best answer” button.