Answer the question
In order to leave comments, you need to log in
Modal window not opening if there is pjax or GridView?
there is a modal button in layout\main
<?php
yii\bootstrap\Modal::begin([
'headerOptions' => ['id' => 'modalHeader'],
'id' => 'my-modal',
'toggleButton'=>['click'],
'size' => 'modal-lg',
]);
echo "<div id='modalContent'></div>";
yii\bootstrap\Modal::end();
?>
<?= Html::button('modal', ['value' => Url::to(['admin/add-device-type']), 'title' => 'title', 'class' => 'modal-test btn btn-success']); ?>
public $js = [
'js/script.js',
'js/jquery-2.2.3.min.js',
'js/app.min.js',
];
$(function () {
$(document).on('click', '.modal-test', function () {
if ($('#my-modal').data('bs.modal').isShown) {
$('#modal').find('#modalContent')
.load($(this).attr('value'));
document.getElementById('modalHeader').innerHTML = '<h4>' + $(this).attr('title') + '</h4>';
} else {
$('#my-modal').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
document.getElementById('modalHeader').innerHTML = '<h4>' + $(this).attr('title') + '</h4>';
}
});
});
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
use yii\helpers\Url;
?>
<div class="col-md-4">
<div class="box">
<div class="box-header">
<h1 class="box-title">Типы оборудования</h1>
</div>
<div class="box-body">
<?= GridView::widget([
'dataProvider' => $device_type,
'layout' => "{pager}{items}",
'tableOptions' => [
'class' => 'table table-bordered table-hover'
],
'columns' => [
'type_name:text:Тип',
'category:text:Категория',
[
'attribute' => 'Удалить',
'format' => 'raw',
'value' => function ($model) {
return Html::a("<span class=\"fa fa-trash-o\"></span>", ['admin/delete-device', 'id'=>$model['id']]);
},
],
],
]); ?>
<?= Html::button('modal', ['value' => Url::to(['admin/add-device-type']), 'title' => 'title', 'class' => 'modal-test btn btn-success']); ?>
</div>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
This is most likely due to a jquery conflict. You connect your jquery in AppAsset, and grid and other elements connect yii\web\JqueryAsset as a result of which you have a conflict (read about resource dependency in yii). Accordingly, you need to exclude the jquery-2.2.3.min.js file from AppAsset
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question