RSS

Automatically showing & hiding a LoadMask for every Ajax request made in Sencha Touch 2

02 Jan

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.

loadingexample

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 requestcompleterequestexception 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.

About these ads
 
21 Comments

Posted by on January 2, 2013 in iOS, Sencha Touch

 

Tags: , , , ,

21 Responses to Automatically showing & hiding a LoadMask for every Ajax request made in Sencha Touch 2

  1. claudio_melo

    January 4, 2013 at 2:42 pm

    so great, i like it.

     
  2. chico_3289

    January 7, 2013 at 1:14 pm

    some great ideas here…

     
  3. camillaferreira

    January 8, 2013 at 1:13 pm

    your post is so valuable for me, it will help in lots of ways.

     
  4. caterinajulia

    January 14, 2013 at 2:36 pm

    i wish i could write so good like you do in your posts.

     
  5. celni

    January 14, 2013 at 2:58 pm

    not bad!

     
  6. carol_princezinha

    January 16, 2013 at 5:05 am

    your website is the most informative. i loved your website a lot. thank you.

     
  7. 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.

     
  8. cintiasanchas

    January 17, 2013 at 3:17 pm

    your work is very appreciated for me, i always read your posts.

     
  9. 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.

     
  10. celiaevagner

    January 21, 2013 at 12:03 pm

    nice site you got here! very informative. highly recommended!

     
  11. carolrmagalhaes

    January 22, 2013 at 2:08 pm

    great article. please keep helping us with your good ideas and your advices.

     
  12. 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.

     
  13. Carlos_varussa

    January 24, 2013 at 2:18 pm

    incredibly awesome.

     
  14. cigana_romantica29

    January 25, 2013 at 10:40 am

    great work by posting this…thanks.

     
  15. Castello

    January 25, 2013 at 2:15 pm

    this one’s very interesting.

     
  16. 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.

     
  17. 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!!!

     
  18. caue_bxd_sp

    January 31, 2013 at 7:20 pm

    excellent article , covers a lot of ground i’ve found a great article. thanks.

     
  19. chico_bala

    February 2, 2013 at 12:33 am

    it’s glad to read this post! i like it.

     
  20. caroline

    February 5, 2013 at 2:14 pm

    keep the good work by posting better posts, as you always do.

     
  21. 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.

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: