mx.login() - Result not always as expected

1
The widget LoginSystem.mpk allows you to setup a different login page. The widget makes use of mx.login(). I expect mx.login() to log in the user and load the home page. This is working perfectly. Until you want to do something else before you log in. In my case, I wanted to load certain css files before showing the home page. Something like this: this.loadCSSDFiles(); mx.login(); In certain cases the loading of css files takes some time as information has to be retrieved from the db via an asynchronous call. In those cases mx.login() gets to be executed before the loading of the css files is finished. The final result of this is that the home page is not getting loaded. Only after a refresh (F5) the home page gets loaded. I solved the problem using dojo.deferred, but I'm wondering if this behaviour of mx.login() is as intended or that this is a bug. Anyone?
asked
1 answers
1

You gave the answer yourself: the css is called via an asynchronous call. In the meantime javascript will proceed. You can solve this with (pseudo):

this.loadCSSDFiles(this.myLoginFunction);
},
myLoginFunction: function () {
    mx.Login();
}

At the end, (or return of async call) of loadCSS.. call the callback function.

This is often done in widgets.

answered