'reset' button for embedded HTML only working once

Hello!

I have a lightbox set up with an embedded HTML map set to a specific point and a ‘reset’ button designed to put the map back on that specific point. After playing around with the code yesterday I got the button working… but will only reset the map once and afterward be unresponsive. Here is the code I’m using:

export function button2_click(event) {
 $w('#html1').src="https://viewer.mapme.com/186d69e8-db95-48cb-afa5-d09adbe06640/location/b9115122-cd63-4137-b6d5-de79b28662a1?showinfo=none"
 }

The URL is the embedded map point.

I have a theory why this might be happening, the map is embedded in the iFrame using the code feature NOT a website address. When the button is hit its replacing the code with the website address, but because they are pointing to the same thing it feels like the map resetting. It only works the once though because it can’t replace the website address with itself for some reason.

This is just a theory though and it could be something else to do with the coding of the button. The fact that I can get it to work even a little though makes me believe this idea IS possible with the right code. Does anyone have any idea how I could get a reset button to consistently reload embedded HTML?

That depends. Could you show the embedded html plus any code that you send to it thru postMessage()?

Hi, yes. So the embedded HTML is set up using this code:


This was copied directly from the mapme site and plugged into wix without any alteration. When setting up the reset button I copied the:

src="https://viewer.mapme.com/186d69e8-db95-48cb-afa5-d09adbe06640/location/b9115122-cd63-4137-b6d5-de79b28662a1?showinfo=none"

directly from this code and used it with the button click event. The lightbox and HTML doesn’t have any additional code and nothing is tied to a wix dataset.

I think I understand what you are trying to do. There are a few options here. We’ll start with the simplest, see if that works: on the button click, first set the .src to undefined or “”. Then followed by the code you already have. Just to see if the map will reset then.

Hi, sorry for the late replay and thank you for the suggestion. I played around with what you suggested this morning and haven’t had much luck yet. First I tried:

    export function button2_click(event) {
    $w('#html1').src=undefined;
    $w('#html1').src="https://viewer.mapme.com/186d69e8-db95-48cb-afa5-d09adbe06640/location/b9115122-cd63-4137-b6d5-de79b28662a1?showinfo=none";
     }

Which behaves the same as my original code, resetting the map but just once. I also get an error in the log saying src has to be a valid URL. This happens both when using “” and ‘undefined’

Next I tried using the full iFrame embed code, but wix says I need to use ‘–jsx’ and I’m not sure if this is a route I should pursue or not.

Its been a few days so not sure you’re still available to help, but would love to hear your other suggestions. I’ll keep playing around with it for now as well

UPDATE:

So I’ve been playing with this today and made an interesting discovery.

After hitting a wall with the above code I created a ‘fake’ reset button that closes and then reopens the lightbox:

import wixWindow from 'wix-window';
    export function button2_click(event) {
        wixWindow.lightbox.close();
    wixWindow.openLightbox("Mehelle Tour 1 Point 1")

    }

This isn’t technically a reset button for the embedded HTML, but it works! Here’s where it gets strange though. Just as with the previous code, this one will only work once. On the first press it will close and reopen the lightbox no problem; on the second press it just closes the lightbox and that’s it.

This makes me wonder if the issue isn’t with the embedded HTML as I thought, but with the button. I don’t know why this could be happening though, there is no other code in the lightbox and it consistently works on the first press.

Any idea whats going on here? While I saw other button issues, googling didn’t return anything on this specific problem. I can also post this as a new question if need be.

Solved here: https://www.wix.com/velo/forum/coding-with-velo/button-in-lightbox-only-works-once