0
這個view.php在Yii2中用CRUD生成,但是刪除按鈕不確認窗口。在yii2中帶有確認的刪除按鈕
但是在用Yii2中的CRUD生成的index.php中,刪除的確認窗口起作用了。在index.php中
<p>
<?= Html::a('Edit', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
<?= Html::a('Back','index', ['class' => 'btn btn-warning']) ?>
</p>
刪除按鈕:
<a href="var/delete?id=2" title="Delete" aria-label="Delete" data-pjax="0" data-confirm="Are you sure you want to delete this item?" data-method="post"><span class="glyphicon glyphicon-trash"></span></a>
刪除按鈕在view.php:
<a class="btn btn-danger" href="var/delete?id=2" data-confirm="Are you sure you want to delete this item?" data-method="post">Delete</a>
所以你的意思的index.php刪除正顯示出確認,但是這一次呢?如果是,那麼檢查兩個按鈕的實際html,你會發現一些差異。克服這種差異,這也將工作 –
我添加代碼差異,但不工作。 – user3770797
我認爲對於JS文件,在view.php中包含來自yii的js文件。 – user3770797