Skip to content

Instantly share code, notes, and snippets.

@JelteMX
Last active December 26, 2022 16:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JelteMX/2fa80d639869cc3b332ad366c76eb2bc to your computer and use it in GitHub Desktop.
Save JelteMX/2fa80d639869cc3b332ad366c76eb2bc to your computer and use it in GitHub Desktop.
Reload languages
var identifier = '.languageButton';
// We use this to make sure jQuery is loaded
$(function () {
var $buttonEls = $(identifier);
if ($buttonEls) {
$buttonEls.each(function () {
var $this = $(this);
var buttonWidget;
try {
buttonWidget = dijit.registry.byNode($this.get(0));
} catch (e) {
console.error('Cannot find widget with class: ' + identifier);
}
if (buttonWidget) {
buttonWidget.connect(buttonWidget, 'onAfterAction', function () {
// window.reloadHandler.reloadPage();
mx.reloadWithState();
});
} else {
console.log('Cannot find widget for', $this);
}
})
}
});
@JelteMX
Copy link
Author

JelteMX commented Nov 22, 2017

screenshot 2017-11-22 16 29 20
screenshot 2017-11-22 16 29 26
screenshot 2017-11-22 17 09 11
screenshot 2017-11-22 17 09 24

@JelteMX
Copy link
Author

JelteMX commented Feb 27, 2018

The new call should be mx.reloadWithState()

@oliviervandevoorde
Copy link

Hi

trying this in mendix 7.10 gave an error on
Uncaught (in promise) TypeError: mx.reloadWithState is not a function

trying this in mendix 7.18 doesn't fire the function attached to the "onAfterAction"

What I'm doing wrong?

@bartrikers
Copy link

Hi Jelte,

We tried implementing the mx.reloadWithState(); function, but the problem is that it looks like the reloaded page is opened 'on top' of the old page, so when you close the page, it looks like nothing happens. My guess is that the new page is actually closed, but then the old page is shown again (the old page is also in the new language, though). So for a user, it looks like nothing happens after the first click on the Close button. After a second click on the Close button, the page is closed. We've seen this same behaviour when a page is refreshed from the modeler after running locally (probably the same function is called then?).

Any solution for this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment