Yii2删除警报框不起作用

时间:2016-02-01 09:47:42

标签: php yii2

我通过Gii生成了模型,控制器和视图,并在index.php中启用了actionColumn。 我有删除按钮删除记录。按钮工作正常,但它没有显示警报框以确认我的行动 我在这附上我的代码。
任何人都可以告诉我缺少什么吗? Index.php

    <?php

use yii\helpers\Html;
use yii\grid\GridView;


$this->title = 'Cities';
$this->params['breadcrumbs'][] = '/ '.$this->title;
?>
<div class="cities-index">

    <h2><?= Html::encode($this->title) ?>
    <?php //echo $this->render('_search', ['model' => $searchModel]); ?>

        <?= Html::a('Create Cities', ['create'], ['class' => 'btn btn-success','style'=>'float:right']) ?>

</h2>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        //'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            // 'country_id',
            [
             'attribute'=>'country_id',
             'value'=>'country.country_name',
            ],
            'city_name',
            'city_tax',

            [   'class' => 'yii\grid\ActionColumn',
                'header'=>'Action',
                'template'=>'{view}{update}{delete}',
                'buttons' => [
                    'view' => function ($url, $model) {
                        return Html::a('<span  class="btn btn-xs btn-success  icon-search bigger-120" style="margin-left:5px;"></span>', $url, [
                                    'title' => Yii::t('app', 'View'),
                        ]);
                    },
                    'update' => function ($url, $model) {
                        return Html::a('<span class="btn btn-xs btn-info icon-pencil blue bigger-120" style="margin-left: 5px;"></span>', $url, [
                                    'title' => Yii::t('app', 'Update'),'<span class="glyphicon glyphicon-search"></span>'
                        ]);
                    },
                    'delete' => function ($url, $model) {
                        return Html::a('<span class="btn btn-xs btn-danger icon-trash  bigger-120" style="margin-left: 5px;" ></span>', 
                            $url, [
                                    'title' => Yii::t('app', 'Remove'),'<span class="glyphicon glyphicon-search"></span>',
                                    'data-confirm' => 'Are You sure',
                                    'data-method' => 'post'
                        ]);
                    },                                    
                ],
            ],
        ],
    ]); ?>

</div>

0 个答案:

没有答案