2016-09-28 38 views
0

我想用jQuery按钮单击事件 按钮在操作列OB GridView控件设计一个custome弹出(不喜欢删除)中的GridView的GridView与弹出

如何与各行的ID添加弹出

+0

使用引导模式。 [阅读此](http://stackoverflow.com/questions/28470166/yii2-modal-dialog-on-gridview-view-and-update-button-shows-same-content-for-both)。 –

回答

2

试试这个, 插入

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')); 
      }); 
     }); 
    "); 

?>