PDA

View Full Version : how can i use event for tree?



hsvitalyi
4 Apr 2007, 8:36 PM
Helo
It is a stupid question, but i am a newbie with it.
I tried to do like this

var tree = new Tree.TreePanel('tree-div', {
animate:true,
enableDD:true,
containerScroll: true
});

tree.click = function(node, e)
{
alert('test');
}

but no result, where am i wrong ? May be event has to be defined some
another way?
Thanks

JeffHowden
4 Apr 2007, 9:03 PM
var tree = new Tree.TreePanel('tree-div', {
animate:true,
enableDD:true,
containerScroll: true
});

That bit by itself won't render a tree. I'm hoping the rest (creation of a root node, assigning that node to the tree, and then rendering the tree) was simply excluded in your post for brevity.



tree.click = function(node, e)
{
alert('test');
}

The syntax in Ext for attaching listeners to things is slightly different:


tree.on('click', function(node, e){
alert('test');
});