[Answered] wix-location -> doens't trigger a reload

I have the situation that I change some local storage information. After this I want to do a ‘reload’. Searching I read to use ‘wix-location’ so I read that documentation page here . Very nice you can get all parts of the URL. For starters, I test the function with a hardcoded URL. The code where I use it is attached to an image like this

export function toggleDutch(event, $w) {
	local.setItem("vttLanguage", "nl");
	$w("#imgDutch").hide();
	$w("#imgEnglish").show();
	wixLocation.to("/overview-list");
}

When I click on the image which is linked to this snippit, the session is set, and an image is hidden/shown. However, the next part is to open a page. This code is working as long as I’m not on the page itself.

Question: What do I need to change to ‘reload’ the page itself?

Hi,
You can reload the page by using the following code:

export function button1_click(event, $w) {
	local.setItem("vttLanguage", "nl"); 
	$w("#imgDutch").hide(); 
	$w("#imgEnglish").show(); 	
	wixLocation.to(wixLocation.url);
}

Best,
Tal.

1 Like

Yep, that does do a reload. I’ll see if i can live with it for it reloads the site. I’m not a huge fan of that for it reacts different then opening a page. E.g. header/footer doesn’t stay frozen but also reloads. In this case I don’t require that. But it’s a solution Thanks

1 Like

i am confused, i am not a coder but i have the same problem when trying to reload my home page, the part of the code that says wixLocation.url. do i have to leave it the way it is or use “wixLocation.home”

wixLocation.to(wixLocation.url);

You should leave it that way…but it looks like there’s an extra .to in the code. So just:

wixLocation.to(wixLocation.url);

@sam-wix Irony, oh irony :https://www.wix.com/corvid/forum/community-discussion/forum-duplication-bug-to-wix-mods?commentId=5d78eb82b1b4030018c9ff72&origin=notification&postId=5d78a15131831400337fc142&replyId=5d79e6836e54c100171f1e1f

1 Like

@giri-zano Good one, although I noticed that Yisrael mentions it will be this Sunday that the fix is released, I was thinking it was already up and running too. :wink: