的GridView与弹出
答
试试这个, 插入
use yii\helpers\Url;
use yii\bootstrap\Modal;
进入u'r的index.php
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Action',
'template' => '{view} {update} {delete} {your_link}',
'buttons' => [
'your_link' => function ($url, $model) {
$url = Url::to(['controller/action', 'id' => $model->id]);
return Html::a(' <span class="glyphicon glyphicon-eye-open" title = "Tooltip Name" ></span> ', 'javascript:void(0)', ['class' => 'anyClassName', 'value' => $url]);
},
],
],
定义模态并将此JS注册到you'r索引文件中
<?php
Modal::begin([
'id' => "modal",
'header' => '<h3>Assign Farmers to other Farm Mitra</h3>',
]);
echo "<div id='modalContent'></div>";
Modal::end();
$this->registerJs(
"$(document).on('ready pjax:success', function() {
$('.list').click(function(e){
e.preventDefault(); //for prevent default behavior of <a> tag.
$('#modal').modal('show').find('#modalContent').load($(this).attr('value'));
});
});
");
?>
使用引导模式。 [阅读此](http://stackoverflow.com/questions/28470166/yii2-modal-dialog-on-gridview-view-and-update-button-shows-same-content-for-both)。 –