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。 –