H
H
haa2018-09-22 16:28:56
Yii
haa, 2018-09-22 16:28:56

Why does the eventOnScroll for ScrollPager not work when I pass data through axios?

I pass data through axios to the search controller

axios.get('/search', {
                    params: {
                        texts: this.text
                    }
                }).then(function (response) {
                    vm.info = response.data
                }).catch(function (error) {
                    console.log(error)
                })

And on the server side I return a listView
$searchText =  Yii::$app->request->get('texts');
            $query = Articles::find()
                            ->where(['LIKE', 'text', $searchText])
                            ->andwhere(['moderation' => 1])
                            ->orderBy('date DESC')
                            ->with(['user', 'cat', 'like', 'commentsAggregation']);

            $dataProvider = new ActiveDataProvider([
                'query' => $query,
                'pagination' => [
                    'pageSize' => 20,
                ],
            ]);

return ListView::widget([
                'dataProvider' => $dataProvider,
                'options' => [
                    'tag' => false,
                ],
                'itemOptions' => [
                    'tag' => false,
                ],
                'emptyText' => 'Записей не найдено',
                'summary' => false,
                'itemView' => function ($model, $key, $index, $widget) {
                    return $this->renderAjax('_ajaxList',['model' => $model]);
                },
                'pager' => [
                    'class' => ScrollPager::className(),
                    'triggerText' => 'Посмотреть еще',
                    'noneLeftText' => 'Записей нет',
                    'spinnerSrc' => '',
                    'spinnerTemplate' => '',
                    'enabledExtensions' => [
                        ScrollPager::EXTENSION_SPINNER,
                        ScrollPager::EXTENSION_NONE_LEFT,
                        ScrollPager::EXTENSION_PAGING
                    ],
                    'eventOnScroll' => 'function() {$(\'.ias-trigger a\').trigger(\'click\')}',
                ]
            ]);

Output per page
<div class="row list-view" v-html="info"></div>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question