P
P
Pepper12019-12-09 11:55:35
Yii
Pepper1, 2019-12-09 11:55:35

How to force PJAX to update on a timer?

How to make PJAX update in YII2 by timer? In reality the gridview is updated 2 times per second. What am I doing wrong?

<?php Pjax::begin(['id' => 'pjax-grid-view', 'timeout' => 60000]); ?>

<?php
$script = <<< JS
$(document).ready(function() {
    $.pjax.reload({container: '#pjax-grid-view', timeout:false})
});
JS;
$this->registerJs($script);
?>
  
  
////все остальное

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

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2019-12-10
@Pepper1

By example:

<?php Pjax::begin([
    'id' => 'list-messages',
    'enablePushState' => false,
    'formSelector' => false,
    'linkSelector' => false,
]) ?>
<?= $this->render('_list', ['dataProvider' => $dataProvider, 'pages' => $pages,]) ?>
<?php Pjax::end() ?>

<?php $this->registerJs(<<<JS
        function updateList() {
          $.pjax.reload({container: '#list-messages'});
        }
        setInterval(updateList, 150000);
JS
    ); ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question