Pjax beforeupdate or afterupdate in yii2

Hi guys

in yii 1.0 there was a nice function beforeAjaxUpdate and afterAjaxUpdate so that we can easily

configure loading image

I cant seem to find that function in yii 2.0

and i am not sure how to achieve that functionality in yii 2.0

let me know if you guys can help

all i want to do is set loading animator in gridview

here is my code




 <?php Pjax::begin(['id' => 'event-grid', 'timeout' => false , ]); ?>

   <?= GridView::widget([

        'dataProvider' => $dataProvider,

        'filterModel' => $searchModel,

        'rowOptions'=> function($modal, $key, $index, $grid) {


            if ($modal->is_active == '0') {

                return ['class' => 'danger action-tr' ];

            } else

                return ['class' => 'success action-tr'];


        },

        'columns' => [

            [

                'attribute' => 'interest_id',

                'label' => 'Event Category',

                'value' => 'interest.area_intrest',

            ],

            'title',

            'description:html',

            [

                'class' => 'yii\grid\ActionColumn',

                'template' => '{checkin/index} {view} {update} {delete} ',

                'contentOptions' => ['class'=>'action-td'],

                'buttons' => [

                    'checkin/index' => function ($url) {

                        return Html::a('<span data-pjax=false class="glyphicon glyphicon-user"></span>', $url,['data-pjax' => true]);

                    },

                ]

            ],

        ]

    ]);

   ?>

    <?php Pjax::end(); ?>



Hi people!

Yes, some years passed, but still no answer…

Anyway this could be a solution for those who still in the search.

PHP




<?php Pjax::begin(['id' => 'pjax_id_1', 'options'=> ['class'=>'pjax', 'loaderId'=>'loader_id_1', 'neverTimeout'=>true]]); ?>

...



JS




$('.pjax').on('pjax:send', function() {

    $('#'+$(this).attr('loaderId')).show();

})


$('.pjax').on('pjax:complete', function() {

    $('#'+$(this).attr('loaderId')).hide();

})



This is loader example, but any function could be added and executed depending on $(this).attr('id)

See below:

JS




$('.pjax').on('pjax:send', function() {

    if($(this).attr('id')=='pjax_id_1'){

        alert('Do something on pjax_id_1 send!');

    }

})


$('.pjax').on('pjax:complete', function() {

    if($(this).attr('id')=='pjax_id_1'){

        alert('Do something on pjax_id_1 complete!');

    }

})



The above is suitable if you have several Pjax containers on one page.