Cgridview CbuttonColumn button ajax call

Hi all,

I am trying to call an ajax function when the button is clicked, everything is ok except that the parameter is no passed.

This is the button definition (is visible $data->id == 5)





            'buttons' => array

                (

                'aceptarAjax' => array

                    (

                    'imageUrl' => Yii::app()->request->baseUrl . '/images/iconos/system-tick-alt.png',

                    'ajax' => true,

                    'click'=>'function(){ajaxUrl("'.

                        Yii::app()->createUrl("cmp/invitacion",array("ec"=>$data->id,"td"=>1))

                    .'"); }',

                    'visible'=>'$data->id==5',

                    'options' => array('title' => 'Aceptar Invitación', 'alt' => 'Aceptar Invitación'),

                ),

            ),




And the testing ajaxUrl function




function ajaxUrl(_url)

{


alert(_url);


return false;


}




shows an alert with /cmp/invitacion/ec//td/1

ec parameter should be 5 ¿how can I do it?

Any ideas?

Look is something with the quotes

Check the documentation for "buttons" - http://www.yiiframework.com/doc/api/1.1/CButtonColumn#buttons-detail

You can use $data only in ‘url’ and ‘visible’ options… for the ‘click’ options this is not evaluated…

so

one idea would be to set the ‘url’ option to the desired url (use the $data)… and than in the click JS function you just read that value…

Great answer.

Solved with this.href

Thanks