1
在gridView中的dataColumn的单元格中,我放置了data-method = post和data-confirm ='Some confirm vessage'的链接。但是,当您单击链接时,它将与get方法一起使用,并且不显示确认消息。为什么它不起作用? 下面是代码:Yii2数据方法发布不在gridView中工作
<?= GridView::widget([
'dataProvider' => new ArrayDataProvider([
'allModels' => $model->orders
]),
'columns' => [
//... some other columns .... Then:
[
'headerOptions' => ['class' => 'bg-teal color-palette'],
'footerOptions' => ['class' => 'bg-teal color-palette'],
'format' => 'html',
'value' => function($model)
{
return Html::a(
'Delete',
[
'order/delete',
'id' => $model->id
],
[
'class' => 'btn btn-primary btn-block',
'data-confirm' => 'Do you realy want to delete the item?',
'data-method' => 'post',
]
);
}
],
]); ?>
如果我放在HTML ::一个GridView控件外,它工作正常。我做错了什么吗?
非常感谢@米洛斯Ozegovic,这工作。也许有人知道其他数据 - 使用我yii2的属性,或在哪里查找信息。 –
我找不到这些属性的任何文档,但我只发现它们中的一些是在yii.js文件中处理的https://github.com/yiisoft/yii2/blob/master/framework/assets/yii.js 我知道有几个属性,data-method,data-confirm和data-params- *,您可以通过它们定义参数以通过数据方法发送。希望你能理解我:) – Imaginaroom
去@Milos Ozegovic。以下是其他数据属性的列表。感谢Bizley。 –