wixLocation.to('/account/my-children/${wixUsers.currentUser.id}');

I am using the same code but sometimes the page is refreshed and sometimes the page is not refreshed. Basically my application has a page with a button that opens up a lightbox. In the light box you can register your children (basic info name, dob, etc). Then when you are done or if you close, I call: wixLocation.to(‘/account/my-children/${wixUsers.currentUser.id}’);

For example if someone clicks on the ‘X’ from the lightbox:
export function xCloseButton_click(event) {
//Add your code for this event [here:](here:
wixLocation.to(‘/account/my-children/${wixUsers.currentUser.id}’);
}
)
[wixLocation.to(‘/account/my-children/${wixUsers.currentUser.id}’);](here:
wixLocation.to(‘/account/my-children/${wixUsers.currentUser.id}’);
}
)
[}](here:
wixLocation.to(‘/account/my-children/${wixUsers.currentUser.id}’);
}
)

The problem is sometimes the page that called the lightbox gets refreshed and sometimes it doesn’t. And I just cant figured out why? The lightbox is not called by my code it is called by Wix gui.

Remember that when you use a lightbox, that the ‘x’ button and the ‘close’ buttons are already setup for you, so you might have the ‘x’ button in the lightbox settings and the onClick event handler function in your code counteracting with each other.

If you want to use code instead, then you will need to delete them and make sure that they are not active in the lightbox settings.
https://support.wix.com/en/article/setting-how-your-lightbox-is-closed

If you do it through code then you might want to add the close lightbox line too so that the lightbox closes before moving the user onto the required page.
https://www.wix.com/corvid/reference/wix-window.lightbox.html#close

So, in your code example above which should be in your lightbox page code tab, you can simply replace the add your code here line with this instead - wixWindow.lightbox.close();

It is the same with opening a lightbox too, you can simply link an element like a button to open your lightbox through the Wix Editor itself.

Or you can use code to open the lightbox for you.
https://www.wix.com/corvid/reference/wix-window.html#openLightbox

However, you can’t have both of them and doing the same thing, you have to have one or the other.

thank you for the reply.
I removed ALL the code to handle the ‘X’ button, and leaving it up to WIX. The ‘X’ button does not refresh the page.

2nd example:
I have page with a button (Register Children) that calls the same Lightbox by WIX gui method not my code. The lightbox after the user provides child’s data clicks a button (button has my code and is not linked by Wix gui)

to register the child in the Children’s collection and the this code at the end:
[wixWindow.lightbox.close();](wixWindow.lightbox.close();
wixLocation.to(‘/account/my-children/${wixUsers.currentUser.id}’);
)
[wixLocation.to(‘/account/my-children/${wixUsers.currentUser.id}’);](wixWindow.lightbox.close();
wixLocation.to(‘/account/my-children/${wixUsers.currentUser.id}’);
)

The page that calls the lightbox sometimes is refreshed and some times it is not (for whatever reason it seems to not refresh the page more times when trying to register a second or third etc child.