Hello. Please help solve the problem with PJAX, I have a form and ListView above, so, after the ListView is updated, focus on the input field disappears, and it turns out that as long as the user enters a message when you update the field focus ListView disappears and the user must press re-press golf continue writing.
<?php echo Html::beginForm(); ?>
<div class = "form-horizontal" role = "form" id = "form_message">
<div class = "input-group">
<?php echo Html::activeTextInput($form_model, 'message', ['class' => 'form-control', 'value'=>'']); ?>
<?php echo Html::activeHiddenInput($form_model, 'group_id', ['value'=>$group_model->group_id]); ?>
<?php echo Html::activeHiddenInput($form_model, 'to_user', ['value'=>Yii::$app->user->id == $group_model->user_to ? $group_model->user_from : $group_model->user_to]); ?>
<span class="input-group-btn">
<?php echo Html::submitButton('Отправить', ['class' => 'btn btn-default']); ?>
</span>
</div>
</div>
<?php echo Html::endForm(); ?>
<?php echo Html::error($form_model, 'message'); ?>
<hr />
<?php
yii\widgets\Pjax::begin(['options' => ['id'=>123, 'timeout'=>3000]]);
echo ListView::widget([
'dataProvider' => $dataProvider,
'itemView' => '_message',
'layout' => "{items}\n{pager}"
]);
yii\widgets\Pjax::end();
$this->registerJs("
function updateMessage(){
$.pjax.reload({container: '#123'});
}
$(document).ready(function(){
setInterval(updateMessage, 3000);
});
");
?>