View Full Version : Loading application config before Viewport is rendered

23 Oct 2013, 12:30 AM
Hello, all.

I use MVC architecture and I want to load some application config JSON (e.g. {"username":"John Doe"}) before viewport has been rendered. I could use Ext.Ajax.request in Ext.app.Application.init template method for this purpose, but it's asynchronized and returns data after viewport is rendered.
How can I do that?

Thank you in advance!

PS. I hope you understand my english :-)

23 Oct 2013, 12:52 AM
When I said "render" I mean "instantiate"

24 Oct 2013, 1:16 PM
Are you wanting to display data on the viewport from the call?

How about updating the display on return of the call instead of delaying the app loading?

Ext.Ajax.on(‘beforerequest’, function (con, opt) {
// mask viewport

Ext.Ajax.on(‘requestcomplete’, function (con, res, opt) {
// update display
// un-mask viewport

Ext.Ajax.on(‘requestexception’, function (con, response, opt) {
// un-mask viewport; display error


24 Oct 2013, 7:28 PM
Thank you for your reply.

But I want not only to display data. This config contains privileges settings that define whether some controls will be displayed.
Can I delay app loading or the only way to that is turn off autoCreateViewport and create viewport manually in ajax callback?

24 Oct 2013, 7:43 PM
create viewport manually in ajax callback

This is what you should do.

25 Oct 2013, 2:39 AM
It is possible to add config as <script> it can be converted to valid a valid javascript command (that's different from json object). Something like: window.App = {config:{}};