Hi,
I would like to create ajaxlinks inside of ctreeview, but I couldn’t load any content from this links (nothing happens in firebug nets section). Could you give me any tips why not?
index view:
<div id="leftContent">
<?php
$this->widget('CTreeView', array(
'id' => 'tree',
'url' => array('ajaxFillTree'),
));
?>
</div>
<div id="rightContent">
<?php echo 'This is rightContent what i would like to update'; ?>
</div>
ajaxFillTree action:
public function actionAjaxFillTree() {
...
$children = $req->queryAll();
$treedata = array();
foreach ($children as $child) {
...
if (isset($_GET['root']) && $_GET['root'] !== 'source') {
$nodeText .= $this->createAjaxLink($id, $child['text'], $type);
}
...
}
echo str_replace(
'"hasChildren":"0"', '"hasChildren":false', CTreeView::saveDataAsJson($treedata)
);
exit();
}
create ajax links in this function:
private function createAjaxLink($id, $text, $type) {
$uniqid = 'send-link-' . uniqid();
$ajaxLink = CHtml::ajaxLink(
$text,
Yii::app()->createUrl(Yii::app()->controller->id . '/mtAjaxRequest'),
// ajaxOptions
array(
'type' => 'GET',
'update' => '#rightContent',
'success' => 'function(data){alert(data);}',
'data' => array('id' => $uniqid),
),
//htmlOptions
array('id' => $uniqid)
);
return $ajaxLink;
}
mtAjaxRequest action:
public function actionMtAjaxRequest($id) {
$this->renderPartial('_ajaxContent', array('id' => $id), false, true);
}
and the ajaxcontent what i want to render:
<?php
echo 'Uniqid is: ' . $id;
?>