samilo
(Samiloxphp)
January 13, 2013, 7:35am
1
Hi
I need to use ajaxlink this my code
////////////// Serach for users
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'adminusers-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'user_id',
'fname_ar',
'lname_ar',
'fa_name_ar',
array(
'name'=>'user_id',
'header'=>'s',
'filter'=>false,
'value'=> "CHtml::ajaxLink('clickMe', array('add',array('event_id'=>$event_id,'user_id'=>\$data->user_id)), array('success'=>'allFine'))",
'type' => 'raw',
)
,
But link had no url ?
How to fix it ?
seenivasan
(Chellamnivas)
January 13, 2013, 9:19am
2
Dear Friend
Kindly check the following is helpful.
value'=> 'CHtml::ajaxLink("clickMe", array("add",array("event_id"=>"'.$event_id.'","user_id"=>$data->user_id)), array(
"success"=>"js:function(data) {console.log(data)}",
))',
Regards.
samilo
(Samiloxphp)
January 13, 2013, 9:32am
3
Thanks seenivasan , but same result No url ?!
in href the value is
href="#"
seenivasan
(Chellamnivas)
January 13, 2013, 9:50am
4
Dear Friend
I am sorry I misunderstood your requirement.
I thought You are finding difficulty in assigning url for ajax response.
CHtml::ajaxLink will not add any url to href attribute.
It assigns only "#".
It triggers ajax response by click event.
Then we have to add the href attribute to htmloptions.
value'=> 'CHtml::ajaxLink("clickMe", array("add",array("event_id"=>"'.$event_id.'","user_id"=>$data->user_id)), array(
"success"=>"js:function(data) {console.log(data)}",
)
array("href"=>CHtml::normalizeUrl(array("event_id"=>"'.$event_id.'","user_id"=>$data->user_id))
)',
samilo
(Samiloxphp)
January 13, 2013, 9:57am
5
my bro , it’s return error
[b]Parse error[/b]: syntax error, unexpected 'array' (T_ARRAY) in [b]H:\xampp\htdocs\yii\framework\base\CComponent.php(607) : eval()'d code[/b] on line [b]4[/b]
seenivasan
(Chellamnivas)
January 13, 2013, 10:02am
6
Just I simulated the scenario in my localhost .I t is working fine.
'columns'=>array(
array(
'name'=>'id',
'value'=>'CHtml::ajaxLink($data->id,array("seeni/two","id"=>"'.$this->id.'"),array(
"success"=>"js:function(data) {console.log(\"ok\")}"
),array(
"href"=>CHtml::normalizeUrl(array("seeni/two","id"=>"'.$this->id.'","od"=>$data->id)),
))',
'type'=>'raw',
),
Just take note of single and double quotes.