6

How to apply a LoadMask for a standard ExtJS MVC application's viewport while it is loading the required files?

An example of such MVC application is the following snippet for app.js:

Ext.Loader.setConfig({enabled:true});

Ext.application({
    requires: [
       'Ext.container.Viewport',
    ],

    name: 'APP',
    appFolder: 'app',

    controllers: [
        'Main'
    ],

    launch: function() {

        Ext.create('Ext.container.Viewport', {
            layout: 'fit',
            items: [
                {
                    xtype: 'main'
                }               
            ]
        });
    }
});

where main above is an xtype for an MVC view, that might extend an ExtJS Panel etc.

Does a standard approach for this ubiquitous requirement exist?

Joseph Victor Zammit
  • 14,760
  • 10
  • 76
  • 102

2 Answers2

5

What you want to do is to show loading image inside your index.html file. something like that:

<div id="page-loader">  
    <img style="position:absolute; width:128px; height:15px; left:50%; top:50%; margin-left:-64px; margin-top: -7px;" src="resources/images/loader.gif" />
</div>

And then hide this div in your launch() function:

if (Ext.get('page-loader')) {
    Ext.get('page-loader').remove();
}
sha
  • 17,824
  • 5
  • 63
  • 98
2

The first solution is good. An alternative is :

http://blog.newbridgegreen.com/extjs-4-splash-screen/

Farandole
  • 539
  • 2
  • 8
  • 23