【发布时间】:2019-08-03 16:51:12
【问题描述】:
我想将ID 传递给使用 Javascript 的另一列。
这是我的代码:
['class' => 'yii\grid\SerialColumn'],
'alumni_id', /*I want to pass this value*/
'tahun_lulus',
'file_excel',
[
'attribute' => 'status',
'format' => 'raw',
'value' => function($data){
return SwitchInput::widget(
[
'name' => 'status_11',
'pluginEvents' => [
'switchChange.bootstrapSwitch' => 'function() {
$.ajax({
method: "POST",
url: "'.Url::to(['/alumni/switch', 'id'=>'1']).'",
data: { status_11: this.checked }
})
}',
],
'pluginOptions' => [
'size' => 'mini',
'onColor' => 'success',
'offColor' => 'danger',
'onText' => 'Active',
'offText' => 'Inactive',
],
'value' => !$data->status
]
);
}
],
我想将属性 alumni_id 传递给那里有 Javascript 的属性 status(到这个 Url::to(['/alumni/switch', 'id'=>'1'])。
我该怎么做?
【问题讨论】:
标签: javascript php ajax gridview yii