Answer the question
In order to leave comments, you need to log in
How to make Kartik-v DetailView and Pjax work?
There is a GridView, also for each model from the GridView there is a button for calling a modal window, inside which a DetailView from Kartik-v wrapped in Pjax.
The first modal window works fine, the subsequent ones cause the page to reload. wtf?
Pjax::begin(['enablePushState' => false, 'id' => 'model-contacts']);
echo GridView::widget([
'dataProvider' => new ActiveDataProvider([
'query' => $model->getContacts(),
]),
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'type',
'title',
'data',
'lat_long',
'comment',
['class' => 'yii\grid\ActionColumn'],
],
]);
Pjax::end();
foreach ($model->contacts as $index => $contact) {
Modal::begin([
'header' => '<h4 class="modal-title">Detail View Demo</h4>',
'toggleButton' => ['label' => '<i class="glyphicon glyphicon-th-list"></i> Detail View in Modal', 'class' => 'btn btn-primary'],
]);
$pjax = Pjax::begin(['timeout' => 3000]);
echo DetailView::widget([
'model' => $contact,
'mode' => DetailView::MODE_EDIT,
'panel' => [
'heading' => 'Контакт #' . $contact->id,
'type' => DetailView::TYPE_DEFAULT,
],
'attributes' => [
'id',
'type',
'title',
'data',
'lat_long',
'comment',
],
'formOptions' => [
'options' => ['data-pjax' => 1],
'enableClientValidation' => false,
],
]);
Pjax::end();
Modal::end();
$this->registerJs("
$('#{$pjax->getId()}').on('pjax:end', function () {
$.pjax.reload({container: '#model-contacts'});
})
");
}
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