How to add ajax-loading indicators

Comparing #1 with #2

Revision #2 was created by rommanc rommanc on Sep 23, 2009, 11:53:49 AM.

Adding method for place array from previous version with ajax options (for more explanation)

Content

[...]
The advantage of this solution is, that you don't have to add extra markup to your page.

When performing the ajax request, add the .loading class to your, usually a div, element. And remove it when the request is complete.

```php
array(
 
 'ajax' =>
<?php 
 
 echo CHtml::form();
 
 echo CHtml::ajaxButton (
 
   'DoAjaxRequest', //label
 
    '', // url for request
 
   
array (    'beforeSend' => 'function(){      $("#myDiv").addClass("loading");
 
  
}',   'complete' => 'function(){      $("#myDiv").removeClass("loading");
 
  
}',    ) );
 
 echo CHtml::endForm();?>

```


The very slim CSS part of this recepie:
~~~
[...]