Loading Indicator

Hi all, i would like to add a loading indicator on form submit. In server when i submit a form, it take much time for submission so on submit click i want to show a loading/progress indicator. In normal form submit how can i add an indicator?

Thanks.

The easiest way is to place the loading image on your page an hide it with css. When the user submits the form set the loading image to display:block.

JS





$('<cssSelectorOfTheForm>').on('submit', function (e) {

 $('<cssSelectorOfTheLoadingImage>').fadeIn();

});






Example form




$form = $this->beginWidget('CActiveForm');

<div class="row">

    <?php echo $form->labelEx($model,'firstName'); ?>

    <?php echo $form->textField($model,'firstName'); ?>

    <?php echo $form->error($model,'firstName'); ?>

</div>

<div class="loading">

  <img src="<pathToLoadingCircle>" />

</div>


$this->endWidget();