public function actionAjaxNews()
 {
     if (Yii::$app->request->isAjax) {
         $model = News::find()->where(['status' => '1'])->orderBy(['id' => SORT_DESC])->limit(5)->all();
         return $this->renderPartial('_news', ['model' => $model]);
     }
 }
 public function actionIndex()
 {
     $query = News::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $model = News::findAll(['status' => 1]);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Beispiel #3
0
       
    });
JS;
$this->registerJs($script);        
/*$(document).ready(function() {
    setInterval(function(){
        $('#refreshButton').click();
    }, 3000);
});

Html::a("Обновить", [Url::toRoute('/')], ['class' => 'hidden',
                                                                                   'id'  => 'refreshButton',
                                                                                    'data-pjax'=>1
                               
                               ]);*/
$news = News::find()->where(['status' => '1'])->orderBy(['id' => SORT_DESC])->limit(5)->all();
?>


                           
                          
                            
                            
                                                             
                   
                           
                           <?php 
Pjax::begin(['id' => 'news-output', 'enablePushState' => false]);
?>
     
                           <table >