我试图在单击按钮时将选定的 id 传递给 js。
我的代码是这样的:
array(
'class'=>'CButtonColumn',
'template'=>'{email}',
'buttons'=>array
(
'email' => array
(
'label'=>'Send an e-mail to this user',
'click'=>'function($data->userId){
var y=confirm("Are you sure to send mail to this user?");
if(y==true){
window.location="todoList/sendEmail/$data->userId";
}
}',
),
),
),
这里我无法在js中获取用户ID。
我在这里能做什么?
最佳答案
好吧,我自己找到了问题的答案。我的工作代码是:
array(
'class'=>'CButtonColumn',
'template'=>'{email}',
'buttons'=>array
( 'email' => array
(
'label'=>'Send an e-mail to this user',
'click'=>'function(){
return confirm("Are you sure to send mail to this user?");
}',
'url'=>'Yii::app()->createUrl("todoList/sendEmail", array("id"=>$data->userId))',
),
),
),
关于java - yii:在js中传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36883989/