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