(SOLVED) Code not working when previewing from dashboard

I’ve added the following code to my home page:

$w.onReady(function () {
$w(“#hoverBox24”).hide();
$w(“#hoverBox20”).hide();
$w(“#hoverBox23”).hide();
$w(“#hoverBox22”).hide();
$w(“#hoverBox21”).hide();
});

This is designed to hide a particular set of hover boxes that have had ‘show on all pages’ turned on for them (The hover boxes show on all the pages except for the home page, where this code exists to hide it)
The code is working absolutely fine on preview mode but when I enter preview from the dashboard home page within my wix account, the code isn’t working and the elements are not hidden; this makes me think it probably won’t work on the live site.

You have basically set up exactly the same as this tutorial here.
https://support.wix.com/en/article/corvid-tutorial-hiding-an-element-on-certain-pages

The only difference is that you have done yours as separate entries, whereas the tutorial combines them all as one entry, however, either way will work for you.

As for preview mode, there is only the one preview mode that you can use within Wix and that is the preview mode from within the editor itself.
https://support.wix.com/en/article/previewing-your-site-5935671

There is no preview mode on the dashboard itself.

As shown above, you can view live site, however no preview mode.

So, if it all works fine in the actual preview mode from within the editor, then it should work fine when you save and publish it too.

Okay, so if you have not published your website then you will have the preview option in your dropdown list choice.


However, I have just tried that on a simple tutorial from Wix and yes I get the same result, that the page does not fully work using this preview option.

Although, note that you are just viewing a saved version of your website through this option and it probably doesn’t give you a complete preview that you get by using the preview from within the editor itself which is an emulator and will show you how your site will look like when tested.

If it works in that preview then the website should work fine when you have published it too.

@brett-haralson
Is there a reason why this preview option for an unpublished site doesn’t work the same as the actual emulator preview from within the editor itself, or is it that it was designed to just be a simple preview and not have the full capabilities of the preview from within the editor itself.

That’s a good question. I’m not sure if a published site executes differently, but I don’t think so. I’m pretty sure preview is intended to be as accurate as published.

@brett-haralson
It does seem strange as I have just opened up this Wix example and tested it.
https://www.wix.com/corvid/example/collapse-elements

Unpublished using the preview site option from the dashboard and the website shows, however none of the onClick event handlers on the container boxes will work, so none of the menu choices of dinner, cocktails, desserts and aperitifs won’t expand and collapse as the tutorial should.

However, when you do actually use the preview option from within the editor itself, the preview does all work fine as it should do.

The published site should in theory be just the same as the saved and unpublished version.

Plus, I would have assumed that the preview site option from the dashboard and the preview site option from within the editor itself, would again in theory be exactly the same.

So it does seem odd that the preview option from the dashboard seems to give the user a limited preview of their website where nothing seems to work.

However, I think I have figured out what it is…

The editor url for unpublished preview site option from the dashboard is:
https://editor.wix.com/html/editor/web/renderer/external_preview/document/71f45286-2dcc-4529-af6e-16ad49f66073?metaSiteId=ea23a0b4-609c-4306-b90b-d15276e68c1b

With the url from the editor preview itself being:
https://editor.wix.com/html/editor/web/renderer/edit/71f45286-2dcc-4529-af6e-16ad49f66073?metaSiteId=ea23a0b4-609c-4306-b90b-d15276e68c1b&editorSessionId=f153ff12-57d2-4dec-a9c7-9159627c1498&referralInfo=dashboard

So just by looking at them, you can see that the first url for the dashboard’s preview site option has put the preview as a document - ’ external_preview/document/ ’ - which would explain precisely why nothing is working in the preview as it is being displayed as a document which would be setup as read only.

I might be wrong, however if it is this issue with it being classed as a document, then do you think that Wix would look at changing it so that both previews are the same and fully workable etc, or would you think that they would probably just leave it set up as it is already.

Finally, it might be mentioned in the Wix Support pages for the dashboard etc, although must users would assume that the preview for an unpublished version would be the same as the preview in the editor itself and would be worried if nothing on their site is working when they preview it from the dashboard option.

@givemeawhisky Thanks so much for looking into this in such detail. I’ve just published the site for a moment to check if the code works and it does!
I’m sorry to cause a bit of a false alarm, I was just a bit nervous about publishing the site as it’s not mine (work for a client) but I received her permission to do so earlier today.
Like you have discussed still seems a bit of a mystery as to how the 2 preview modes differ from each other but for now this issue is solved for me.

Thanks for this - will follow up internally.

No worries about it as you have raised the issue that the previews are two different varieties when in fact they should really be exactly the same, or at least mentioned on the dashboard preview that it is just a basic read only type of preview and nothing will actually be workable etc.

@brett-haralson
Would be interesting to know why Wix decided to go down the route of having the two different types of previews, especially when most users would assume that it would just be a normal preview and be expecting their site to work and then panic when it doesn’t do anything!

I brought this up internally - should have an answer soon.

Hi,

The different previews is weird. Thanks for bringing it to our attention. I’ll open a bug on it and in the meantime we’ll document it.

Re Preview vs. Publish: Most of the time functionality should be the same, but not always. Certain APIs only work in the Published site, for example some Members APIs. Also some backend events. Any time that is the case we mention it in the reference docs. We also mention it here: https://support.wix.com/en/article/corvid-testing-and-debugging-your-code#testing-in-preview-mode-1

-Jeff

Thanks Jeff,

Plus, yes I am aware of the fact that certain Wix API will only fully work in the live version of your site, as you have mentioned with the APIs like Wix Users.

However, most users of Wix who won’t use Corvid will no doubt just automatically assume that the preview inside the Wix Editor and the preview from the Wix Dashboard would be one and the same and therefore would be expecting to have the same result through both methods of previewing.

Although, looking back at it now, I can somehow see the Wix logical way of thinking here and only giving the user a fully working preview when they are actually using the preview mode through the Wix Editor itself, with only a basic preview when shown through the Wix Dashboard only.

So, to be perfectly honest here, I am actually surprised that it has taken this long for somebody to pick up on the fact that they are different previews, or they have just seen it and panicked themselves and have gone into the Wix Editor thinking that their site is wrong and checked it over to fix it and then viewed it back through the Wix Editor preview and then assuming it is all working again, closed and logged out without again checking the preview through the Wix Dashboard to see that it is still a different preview.