2

如何添加删除确认对话框

SideNav::widget([
    'type' => SideNav::TYPE_PRIMARY,
    'encodeLabels' => false,
    'heading' => '<i class="glyphicon glyphicon-cog"></i> Operations',
    'items' => [
        [
            'label' => 'Home',
            'icon' => 'home',
            'url' => Url::to(['/site/home', 'type' => $type]),
            'active' => ($item == 'home'),
        ],
        [
            'label' => 'Delete',
            'icon' => 'trash',
            'url' => Url::to(['delete', 'id' => $model->id_pd]),
            'linkOptions' => ['data' => ['method' => 'post', 'confirm' => 'Apakah yakin']],
        ],
    ],
]);
4

1 回答 1

1

我的问题有一个答案:

SideNav::widget([
'type' => SideNav::TYPE_PRIMARY,
'encodeLabels' => false,
'heading' => '<i class="glyphicon glyphicon-cog"></i> Operations',
'items' => [
    [
        'label' => 'Home',
        'icon' => 'home',
        'url' => Url::to(['/site/home', 'type' => $type]),
        'active' => ($item == 'home'),
    ],
    [
        'label' => 'Delete',
        'icon' => 'trash',
        'url' => Url::to(['delete', 'id' => $model->id_pd]),
        'template' => '<a href="{url}" data-confirm="Are you sure you want to delete this item?" data-method="post">{icon}{label}</a>'
    ],
],
]);
于 2018-05-24T01:55:56.837 回答