Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJS 4.1 MVC: How to apply LoadMask to viewport while loading?

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?

like image 427
Joseph Victor Zammit Avatar asked Jul 10 '12 12:07

Joseph Victor Zammit


2 Answers

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();
}
like image 117
sha Avatar answered Nov 20 '22 22:11

sha


The first solution is good. An alternative is :

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

like image 2
Farandole Avatar answered Nov 20 '22 21:11

Farandole