PDA

View Full Version : TreePanel Listeners scope



Phjeerable
12 Sep 2008, 10:01 AM
I have a TreePanel object I've created that loads the tree via a TreeLoader object. I would like to obtain the leaf's ID when I click on it, but I don't know which scope to use for that.
Here is some code:


var tree = new Ext.tree.TreePanel({
el: 'tree-poses',
animate: true,
autoHeight: true,
autoScroll: true,
bodyBorder: false,
loader: new Ext.tree.TreeLoader({
dataUrl:'http://dev.***.com/?route=chat/pose_list'
}),
rootVisible: false,
singleExpand: true,
listeners: {
"click": {
fn: onPoseClick,
scope: this
}
}
});

The scope of "this" will not provide me with the element ID of the leaf. Which scope do I use to be able to access the leaf ID in the onPoseClick function?

Animal
12 Sep 2008, 10:24 AM
If you read the docs, the click handler is passed the clicked node.

Phjeerable
12 Sep 2008, 10:50 AM
Doh :">

Thanks, I was looking too much into it.