This post describes an easy way to show and hide a Load Mask automatically for every Ajax request made in Sencha Touch 2 based application.
Usually, Load mask is used to indicate the user that something was happening in the background and also it prevents the user action until the application finished the current process.
It is achieved in the sencha touch based application by simply Adding the mask to the Viewport in the beforerequest event of ajax control and removing it in the requestcomplete & requestexception event of ajax control.
//Fires before a network request is made to retrieve a data object.
Ext.Ajax.on(‘beforerequest’, function (con, opt) {
//To show the mask
Ext.Viewport.setMasked({
xtype: ‘loadmask’,
message: ‘Please wait…’,
indicator: true
});
}, this);
//Fires if the request was successfully completed and hide the mask.
Ext.Ajax.on(‘requestcomplete’, function (con, res, opt) {
//To hide the mask
Ext.Viewport.setMasked(false);
}, this);
//Fires if an error HTTP status was returned from the server and hide the mask.
Ext.Ajax.on(‘requestexception’, function (con, response, opt) {
//To hide the mask
Ext.Viewport.setMasked(false);
}, this);
So it will display the load mask once the request is made and hiding the mask once the request is completed or received an error status automatically.
That’s it.

claudio_melo
January 4, 2013 at 2:42 pm
so great, i like it.
chico_3289
January 7, 2013 at 1:14 pm
some great ideas here…
camillaferreira
January 8, 2013 at 1:13 pm
your post is so valuable for me, it will help in lots of ways.
caterinajulia
January 14, 2013 at 2:36 pm
i wish i could write so good like you do in your posts.
celni
January 14, 2013 at 2:58 pm
not bad!
carol_princezinha
January 16, 2013 at 5:05 am
your website is the most informative. i loved your website a lot. thank you.
ciclone_22mm
January 17, 2013 at 2:42 pm
thank you for being so good at writing and giving information, you do it very well, and your website is very good too, congratulations.
cintiasanchas
January 17, 2013 at 3:17 pm
your work is very appreciated for me, i always read your posts.
claudioflosi
January 21, 2013 at 10:46 am
excellent post. fascinating reading. i’d be happy to have you submit your article links for any future postings such as these you feel might be useful for your readership.
celiaevagner
January 21, 2013 at 12:03 pm
nice site you got here! very informative. highly recommended!
carolrmagalhaes
January 22, 2013 at 2:08 pm
great article. please keep helping us with your good ideas and your advices.
cavernadodede3
January 24, 2013 at 11:38 am
your blog is really excellent. it inspires the readers who have that great desire to lead a better and happier life. thanks for sharing this information and hope to read more from you.
Carlos_varussa
January 24, 2013 at 2:18 pm
incredibly awesome.
cigana_romantica29
January 25, 2013 at 10:40 am
great work by posting this…thanks.
Castello
January 25, 2013 at 2:15 pm
this one’s very interesting.
calor
January 28, 2013 at 6:19 pm
hey i visited the site…it is a nice site. thanks for providing information here…i like your blog post too thanks a lot.
mestreseo
January 30, 2013 at 7:00 pm
your post is really good and informative. i’m surprised that your post has not gotten any. good quality, genuine comments. you have done a great job by posting this article. thanks!!!
caue_bxd_sp
January 31, 2013 at 7:20 pm
excellent article , covers a lot of ground i’ve found a great article. thanks.
chico_bala
February 2, 2013 at 12:33 am
it’s glad to read this post! i like it.
caroline
February 5, 2013 at 2:14 pm
keep the good work by posting better posts, as you always do.
cari_kkk
February 5, 2013 at 4:06 pm
excellent article, thanks very much for this information. happy to have found this post. it’s interesting.