java - yii:在js中传递参数

标签 java yii

我试图在单击按钮时将选定的 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/

相关文章:

java - 使用堆栈的汉诺塔

java - Maven 的新手在 Netbean 中创建 Maven 项目时出错

java - 时间戳到字符串到日期时间问题

php - yii2 中使用 Active Record 的复杂数据库查询

php - 在 Yii PHP 模块内部使用主题布局

php - 允许 WebRoot-Directory 访问上层目录

java - Optional#map 可以将输入参数的状态更改为 Function lambda 吗?

java - 为什么这个枚举类型没有正确解析?

yii - 为什么我们在操作管理中使用 $model = new ModelName ('search' )?

html - 如何使用 render() Yii 将 anchor 发送到 URL