the ajax link simply call the action,what i need is to update the tr with the id="youtr" after the action change the variable to show the content,i have tested with a div inside td but is the same result
In a grid view, if ‘decollage’ field is null (db defaults), an ajaxLink with #id 'deco4, ‘deco2’ … is displayed, otherwise the $data->decollage value is shown.
it checks the ajaxRequest, load model, set the value and echo the result wich will replace (note the javascript ‘replaceWith’) the ajaxLink
/**
* Set the decollage of a particular model.
* @param integer $id the ID of the vol model to be set as decollage
*/
public function actionDecollage($id)
{
if(Yii::app()->request->isAjaxRequest){
$now=date('H').':'.date('i').':00';
$model=$this->loadModel($id);
$model->decollage=$now;
$model->save();
echo $now;
}
}
<table><tr><td>
<?php
echo CHtml::ajaxLink('<img title="YouTube" src="' . Yii::app()->request->baseUrl . '/images/youtube-icon.png" alt="youtube-icon.png" />',
$this->createUrl('displayYouTube'),
// this should work ... give a try
array("success"=>"function(responseText){$(\'#youtr\').update(responseText);}"),
// or maybe that can work too ?
array('update' => '#youtr'));
?>
</td></tr>
<tr id="youtr"><td>your initial content</td></tr>
</table>
in your controller:
public function actionDisplayYouTube(){
$result = "<td>What ever you want to display</td>";
echo $result;
}
btw: processing ad I suggest doesnt follow a strict MVC design because of creating html stuff in the controller, so there must be for sure a better solution, but I don’t know how to deal with that …