Page 1 of 1

trigger page refresh when a specific menu item is hit

Posted: 24 Jul 2020, 06:34
by ckishappy
Hi, I moved my website data to my Nginx web server last night. I realized it is some years by now that I touched x3.. bear with me.

I have two languages (DE and EN) for www.polaschin.ch and would like to trigger a page refresh once EN is chosen to ensure that the English menu is refreshed (as typically the menu wouldn't be refreshed and stay in German)..

Please advise with any thoughts or pointers to make this two language setup work again. Br, Chris

Re: trigger page refresh when a specific menu item is hit

Posted: 25 Jul 2020, 00:24
by mjau-mjau
The reason it doesn't refresh when navigating from primary language (DE) to secondary language (EN), is because the X3 menu considers /en to be a relative X3 link, and loads the page via ajax, without refreshing the entire page and menu. It's a bit stupid that this behavior cannot easily be changed, but I have a Javascript fix for you. Go to Settings > Custom > Custom Javascript, and copy-paste the following:
Code
function x3_load_page(){
 setTimeout(function(){
   document.querySelector('[href="https://polaschin.ch/en"]').classList.add('no-ajax');
 }, 500);
}
We just need to add the no-ajax class to the link, to prevent X3 from hi-jacking the navigation.

Re: trigger page refresh when a specific menu item is hit

Posted: 25 Jul 2020, 04:11
by ckishappy
ah the famous x3_load_page function! Thanks for the reminder and this works like a charm!!