I have a CTreeView, I want to do a different action according to the element has been clicked, but how can I intercept this event?
I see that CtreeView is a list with <UL> <LI> <LI>… So I think I should insert the event "onclick" foreach <LI>
but how can I do it in CTreeView?
In DropDownList I can specify in htmloptions differents options for example:
dropDownList ($name, $select, $data, $htmlOptions=array (
'options'=>'value1'=>array('onclick'=>'xxxx'),
'value2'=>array('onclick'=>'yyyy')))
For CtreeView I tried this solution but it seems not possible.
Another solution should be insert the "onclick" in the UL tag and then according to the index clicked, with Javascript, do the right action, for example:
$this->widget('CTreeView',array('data'=>$data,'animated'=>'fast','collapsed'=>true,
'htmlOptions'=>array('onclick'=>'if (indexclicked==xxxx)...')));
the problem is how can I understand wich index is clicked with javascript? For dropdownlist I can use
if (this.options[this.selectedIndex])=='xxxx' ...
there is a similar syntax for UL list?