Hide elements on certain pages

Hi all,
I’ve set a number of items to only show on certain pages as per the instructions here (Velo Tutorial: Hiding an Element on Certain Pages | Help Center | Wix.com)
When going into preview initially the elements are indeed hidden, however when navigating through the site and heading back to the pages where the elements should be shown they have unfortunately disappeared. Website preview - http://wix.to/aEBnAFY

Any help much appreciated.
Cheers
Bob

Hi Edward:

I haven’t seen your code but let me throw some ideas out to you.

#1: (My best guess) Wix has two code areas per page (page and site) These are identified by tabs in the code editor on the left side of the page. Wix web sites are essentially single page sites that refresh when items are clicked or other actions taken. When you navigate between pages the page code will change. The site code will not.

What this means is that if your menu is managed in site code and you set the element(s) to hide() then they will stay hidden for every page you navigate to there after. So you need to manage the hide and show in you page code somehow. Every page (and the site) has an onReady(0 function you can write.

$w.onReady(() => {
   // do stuff
}

You ca try to check the state of your element(s) in the page onReady code (not site). Then determine if you want to make the elements visible if they are invisible.

$w.onReady(() => {
    if ($('#hideableElement').hidden) {
        // Need to show this
        $('#hideableElement').show();
   }
});

#2: (Perhaps a better technique ) Consider using a Lightbox (Wix Editor: Adding and Setting up a Lightbox | Help Center | Wix.com). What a light box can do is help you build self contained code that can either exist on every page or only on the ones you want. Light boxes can be made to appear in code using the wix-windows.openLightbox() function and can be asked to go away using their built in ‘X’ and Close buttons. There is also a way to close a lightbox using its own close() function but you probably won’t need that.

Lightboxes are a good way to create menus that you can use, say a hamburger button, to open and close.

Hope that helps.

Steve

Hi Steve,

Thanks for the your input, really appreciate it!

I was reviewing the website on a different computer last night and noticed that the element acted as normal. I normally use a Mac with Chrome, however this was on windows 8 with firefox.
I tried on a few different browsers on the Windows computer, however the problem remained.
This morning I’ve tried the page on my Mac but through Firefox to see if it works. Sadly not, so quite confused as to what’s going on.
Any thoughts? If not I’ll give your option 2 a go.

Thanks again,
Bob

Just to note, I’ve not changed any code yet.

Hi Edward

Now you are getting into an area that is kind of a minefield. This may not be a platform (Windows vs Mac) issue it is more likely to be a browser and browser version issue.

Windows 8 is kind of an old platform (2012) and the version of firefox that you are using might not support some of the react / javascript code that your wix page is loading. So you might get some odd effects.

I would look at the browser version and see what javascript (ECMA Script) version it supports. If the version is an older version then you probably should try upgrading the browser?

Anyway pay attention to this:

Also posts such as this suggest that Wix isn’t testing all os - browser combinations so there may be a compatibility issue that you have discovered.

1 Like

Hi Steve,

Just letting you know I managed to sort out the issue with the ‘hidden elements on certain pages’. I re did all the elements as new text buttons and that seemed to work.

Thanks for your help all the same!

Bob

1 Like