Yii Framework Forum: Ajax Busy Indicator - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ajax Busy Indicator Rate Topic: -----

#1 User is offline   thor76 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 08-May 13

Posted 15 May 2013 - 11:01 AM

Hi,

I want to add that busy indicator that f.e. appears when changing the page size of a CGridView to my view.

Thanks in advance
0

#2 User is offline   Tsunami 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 150
  • Joined: 16-February 12

Posted 15 May 2013 - 12:01 PM

By default CGridView already has a loading indicator when it's updating using AJAX. It's controlled by the "grid-view-loading" CSS class.
0

#3 User is offline   thor76 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 08-May 13

Posted 16 May 2013 - 03:36 AM

Thanks for your reply. The CGridView reference was just an example. I have a table that updates using ajax when I change a drop-down list. The table needs some values to be calculated before they are shown, so I need the indicator during that update. What's the best way to show the busy indicator?
0

#4 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,670
  • Joined: 04-March 10
  • Location:UK

Posted 16 May 2013 - 04:01 AM

The CGridView image is packaged up with the CGridView assets here.

If you want to use the same image for other parts of your site, the easiest option might be to copy the image into a web accessible images directory and create a javascript file for your site to handle the showing and hiding of the image under certain circumstances.

For a more encapsulated approach, you could create a widget to publish and output the loading image and surrounding HTML with a unique ID. The widget could also publish javascript and CSS files to handle the display of the image.
0

#5 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 16 May 2013 - 04:21 AM

You could add in your main layout for instance a script that handles that, or in your external JS file if any. That script would use a couple of Ajax Events, see for instance:


0

#6 User is offline   sefburhan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 137
  • Joined: 08-February 12
  • Location:islamabad

Posted 17 May 2013 - 12:40 AM

View Postthor76, on 15 May 2013 - 11:01 AM, said:

Hi,

I want to add that busy indicator that f.e. appears when changing the page size of a CGridView to my view.

Thanks in advance


You can add or remove any htmp entities/class upon an event
Yii::app()->clientScript->registerScript('search', "

$('.search-form form').submit(function(){
$.fn.yiiGridView.update('l3answers-grid', {
'success': function(data) { // you can use whatever you want like complete, beforecomplete,etc
addClass('somethinghere'); // remove class
},
data: $(this).serialize()
});
return false;
});
");
see its documentation
http://api.jquery.com/jQuery.ajax/

and CGridview
http://www.yiiframew...i/1.1/CGridView
http://stackoverflow...e-yii-framework
0

#7 User is offline   thor76 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 08-May 13

Posted 17 May 2013 - 03:41 AM

Thanks all, I got it working.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users