I’m trying to use infinitscroll extension of yii for my ListView but it’s not working if I submit a form using pjax or even ajax
this is my form
<?php
$this->registerJs('
$("#new_comment").on("pjax:end", function(e) {
console.log ('.$postID.')
$.pjax.defaults.timeout = false;
$("#comments").load(" #comments");
e.stopPropagation();
});
');
?>
<div class="comments-form">
<?php yii\widgets\Pjax::begin(['id' => 'new_comment']) ?>
<?php $form = ActiveForm::begin(['id' => 'form-comment',
'options' => ['data-pjax' => true, 'enctype' => 'multipart/form-data']]); ?>
<?= $form->field($modelCmt, 'comment_Text')->textInput(['maxlength' => true, 'id' => 'commentText']) ?>
<?= Html::input('hidden', 'post_id', $postID, ['id' => 'hdnInp']) ?>
<div class="form-group text-right">
<?= Html::submitButton(Yii::t('app', 'Add comment'), ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
<?php yii\widgets\Pjax::end() ?>
</div>
and my listview is :
<div class="chn-comment-view">
<?php Pjax::begin(['id' => 'comments']); ?>
<?= ListView::widget([
'dataProvider' => $comments,
'summary'=>'',
'itemOptions' => ['class' => 'item'],
'emptyText' => 'No Comments',
'itemView' => function ($model, $key, $index, $widget) {
return $this->render('pst-comment-table',['model' => $model]);
},
'pager' => ['class' => \kop\y2sp\ScrollPager::className()],
]);
?>
<?php Pjax::end(); ?>
</div>