One of the nice features of using Sencha Touch (and ExtJS for that matter) lists (Ext.dataview.List) is that you can simply set the parameter masked to true and when the store retrieves data, a nice “loading” make appears letting your user know that something is happening and the browser is just not frozen while we wait for data. (example follows):
Ext.create('Ext.List', {
fullscreen: true,
itemTpl: '{title}',
store: 'mystore',
masked: { xtype: 'loadmask',message: 'loading' }
});
If you want to get data using Sencha Touch and the Ext.Ajax method, you don’t get this nice masked option so you have to do it yourself.
The strategy is basically this:
he below method is actually calling a Microsoft ASP.NET WebAPI server. I’ve put a Thread.Sleep(3000) in the service call so I can see the load mask happening in testing.
var basePanel =
Ext.ComponentQuery.query("toppanel")[0];
var loginFormPanel =
Ext.ComponentQuery.query("loginformpanel")[0];
var task = Ext.create('Ext.util.DelayedTask', function() {
Ext.Viewport.mask({ xtype: 'loadmask',
message: "Checking Credentials.." });
}, this);
task.delay(500);
// do login and if success,
// flip, otherwise show error
Ext.Ajax.request({
url:'/rpc/Account/Login',
params: {
Username: loginFormPanel.getValues().username,
Password: loginFormPanel.getValues().password,
RememberMe: loginFormPanel.getValues().rememberMe != null
},
success: function(response){
task.cancel();
Ext.Viewport.unmask();
basePanel.animateActiveItem(1,{type: 'flip' });
},
failure: function() {
task.cancel();
Ext.Viewport.unmask();
Ext.Msg.alert("Login Failed");
}
});
HTH’s!