Yii2: Implement an loading Image

Created on 8 May 2016  ·  4Comments  ·  Source: yiisoft/yii2

What steps will reproduce the problem?

I'am new in yii2. I wanna show an loading image after user click the link.

index.php

<style type="text/css">

    .loading{
       background-image: url('http://dkclasses.com/images/loading.gif');
       background-position: center center;
       background-repeat: no-repeat;
    }

    .error
    {
       background-image: url('http://dkclasses.com/images/loading.gif');
       background-position: center center;
       background-repeat: no-repeat;
    }

</style>

<?php
use yii\helpers\Html;    

echo Html::a(
        'Go To the link',
        array('users/datum'),
        array(
            'update'=>'#resultat',
            'beforeSend' =>"function(){
                   $('#colorId').addClass('loading'); 
            }",
            'complete'=>"function(){ 
                $('colorId').removeClass('loading');
            }",
            'error'=>"function(){ 
                $('colorId').addClass('error');
            }"
        )
        );
?>

<div id="colorId" class="loading"></div>

<div id="resultat">
    Hello World
</div>

UsersController.php
public function actionIndex() { return $this->render('index'); }

What is the expected result?

I couldnt see the loading image. Any one knows where can be the problem.

What do you get instead?

Additional info

| Q | A |
| --- | --- |
| Yii version | |
| PHP version | |
| Operating system | |

question

All 4 comments

'#resultat' - палишься
а вообще тебе на форум

No. not #resultat is not the Problem. but thank you

_This is an automated comment, triggered by adding the label question._

Please note, that the GitHub Issue Tracker is for bug reports and feature requests only.

We are happy to help you on the support forum, on IRC (#yii on freenode), or Gitter.

Please use one of the above mentioned resources to discuss the problem.
If the result of the discussion turns out that there really is a bug in the framework, feel free to
come back and provide information on how to reproduce the issue. This issue will be closed for now.

i am registered in the http://www.yiiframework.com/forum/ but i can not start a new Topic.

Was this page helpful?
0 / 5 - 0 ratings