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?
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();
}
The first solution is good. An alternative is :
来源:https://stackoverflow.com/questions/11413337/extjs-4-1-mvc-how-to-apply-loadmask-to-viewport-while-loading