Answer the question
In order to leave comments, you need to log in
how to ajax update a widget in yii2?
Good day, I want to make receiving new notifications (in the widget) in the admin panel via ajax. Logically, I understand that you just need to update the widget after n amount of time.
My actions:
Added my widget to pjax - main.php
<!-- Header and Sidebar -->
<?php \yii\widgets\Pjax::begin(['id' => 'pjax-container']); ?>
<?php echo \backend\components\HeaderWidget::widget()?>
<?php \yii\widgets\Pjax::end(); ?>
//код... менюшка + хедер
<?php
$script = <<< JS
$(document).ready(function() {
setInterval(function(){ $.pjax.reload('#pjax-container'); }, 5000);
});
JS;
$this->registerJs($script);
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question