I try to update content with ajaxLink like in this example ( http://www.yiiframework.com/doc/cookbook/49/ ) but I create ajaxLink not in view but in controller. These links are created in ajax method ajaxFillTree and they are text proporties in CTreeView widget. Tree is created dynamically in ajaxFillTree. If I try to click in thats links there is no actions.
Method in ajaxFillTree:
public function actionAjaxFillTreeJednostki(){
if (!Yii::app()->request->isAjaxRequest) {
exit();
}
$parentId = 0;
if (isset($_GET['root'])) {
$parentId = (int) $_GET['root'];
}
$children = Jednostki::model()->findAllByAttributes(array('rodzic'=>$parentId));
for($i=0;$i<sizeof($children);$i++){
$data[$i]['text'] = CHtml::ajaxLink(
$children[$i]->nazwa,
CController::createUrl('sis/UpdateAjax'),
array( 'update' => '#data',
'type'=>'GET',
'data'=>array('id'=>$children[$i]->id),
)
);
$maDzieci = Jednostki::model()->findByAttributes(array('rodzic'=>$children[$i]->id));
if(isset($maDzieci)){
$data[$i]['hasChildren']=true;
}
else{
$data[$i]['hasChildren']=false;
}
$data[$i]['id']=$children[$i]->id;
}
echo CTreeView::saveDataAsJson($data);
exit();
}
Method ajaxUpdate
public function actionUpdateAjax()
{
$data = array();
$id = $_GET['id'];
$data['info']='to jest ajax, id: '.$id;
$data['dInformacje'] = Jednostki::model()->findByPk($id);
$this->renderPartial('_ajaxContent', $data, false, true);
}
}
View wyswielt.php
<div id="data">
<?php echo $this->renderPartial('_ajaxContent',array(
'info'=>$info,
'dInformacje'=>$dInformacje,
));
?>
</div>
View _ajaxContent.php
<div id="informacje_glowne">
<?php echo $info;?>
<?php echo "<br />".$dInformacje->nazwa?>
</div><!-- informacje_glowne -->
Where is a problem?