I’m having trouble with
I’m having trouble making a menu open when I click a button on the page.
Working in
WIX Studio
Site link
Can’t share a link, sorry.
What I’m trying to do
I have a sharing menu much like the mobile hamburger menu that is accessible from desktop too. And I want it to be able to pup up and show not only from the button in the header, but also a few pages have a button in them that opens it too.
Currently… when I press one of the buttons, all that happens is the screen becomes dim, like it does when the menu is opened from the header, but the actual menu container doesn’t appear.
What I’ve tried so far
So far I’ve tried .open() as well as show(), expand(). I’m not sure what else there is.
Extra context
below is the menu open when I click via the “Share” button in the header
Below is what happens when I click one of the buttons. The screen dims, but the menu container doesn’t appear.
I’m guessing this is custom - can you share the code you have? Where you’ve added it? And how this is structured - e.g. is this a Popup or a container in the header etc.
Something else to consider is using the out of the box option for adding a share button to the page - Studio Editor: Adding and Customizing Share Buttons | Help Center | Wix.com
I can’t seem to be able to add more different platforms to share with. I used a menu: ‘Hamburger Menu Container #hamburgerMenuContainer3’
$w('#btnShareMenu').onClick((event) => {
$w("#shareMenu").scrollTo();
if ($w("#hamburgerMenuContainer3").opened) {
$w("#hamburgerMenuContainer3").close();
} else { $w("#hamburgerMenuContainer3").open(); }
});
#shareMenu
- menu button in header created with the menu
#hamburgerMenuContainer3
- container for the dropdown menu
#btnShareMenu
- Bew button on page to open Sharing Menu Container
I made a screenshot video, but I can’t seem to add it on here
I wouldnt use the hamburger menu.
I would build using a lightbox or a container.
Exactly as Dan suggested
A Popup is probably the best way to go. Here’s how I’d approach it:
- Button in the Header of the site with a normal link (not via code), that opens the Popup
- In the popup, add a series of buttons for all the platforms you want people to be able to share on - replacing the buttons label/icons, and giving it a meaningful ID so it’s easier to work with in code.
- Then in the Popup, add code similar to the following:
import * as wixSiteLocation from '@wix/site-location';
let currentPage;
$w.onReady(async function () {
currentPage = await wixSiteLocation.location.url();
$w("#fbShareBtn").link = "https://www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(currentPage);
$w("#fbShareBtn").target = "_blank";
});
Then repeat for each link 