CodeThatTree - Property onopen, onclose
<script language="javascript1.2">
<!--
var TreeDef = {
"style" :
{
"imgitem" : "tree/img/item.gif", // Image for leafs
"imgdir" : "tree/img/open2.gif", // Image for directories
"imgdiropen" : "tree/img/close2.gif", // Image for directories in open state
"itemoffset" : {
"x" : "10", "y" : "0"
}, // Offset for a next tree level
"css" : "test2tree",
"color" : "#00008B",
"fixwidth" : 200
},
"position" : {
"absolute" : true, "pos" : [10, 15]
},
"styleover" : {
"bgcolor" : "#D3E5FA", "css" : "test2tree", "color" : "#00008B"
},
// Main items array. In this case has one item Item1
"items" : [
{
"text" : "Item1", "id" : "Id1",
"onopen" : "window.alert('Item 1 is opened!')",
"onclose" : "window.alert('Item 1 is closed!')",
// Subtree definition
"menu" :
{
// Subitems array.
"items" : [ {
"text" : "Item11"
},
{
"text" : "Item12"
},
{
"text" : "Item13"
} ]
}
},
{
"text" : "Item2",
"onopen" : "window.alert('Item 2 is opened!')",
"onclose" : "window.alert('Item 2 is closed!')",
// Subtree definition
"menu" :
{
"style" : {
"imgitem" : "tree/img/item2.gif"
},
"items" : [ {
"text" : "Item21"
},
{
"text" : "Item22"
},
{
"text" : "Item23"
} ]
}
} ]
};
var t1 = new CTree(TreeDef, "sample");
t1.create();
t1.draw();
//-->
</script>