title: Extended ExtJS Class can't find custom listener function - "oe is undefined"
body: <p>I'm adding a custom context menu to a TreePanel.
  This was all working when I had a separate function for the context menu, but I was having problems where the context menu items would end up doubled/tripling up if I clicked on one of the options and then viewed the context menu again.</p>
  
  <p>I had a look around for other contextmenu examples and came up with <a href="http://www.extjs.com/forum/showthread.php?p=84588#post84588" rel="nofollow noreferrer">this one by Aaron Conran</a> I pretty much "stole" it wholesale with a few additions, tacking the function directly into the Ext.ext.treePanel config. This gave me an error about "oe is undefined" which seemed to refer to "contextmenu: this.onContextMenu" in the tree config.</p>
  
  <p>I figured it was probably something to do with the way I was defining all of this, so I decided to look at extending Ext.ext.TreePanel with my function in it as a learning exercise as much as anything.</p>
  
  <p>Unfortunately, having managed to sort out extending TreePanel I'm now back to getting "oe is undefined" when the page tries to build the TreePanel. I've had a look around and I'm not really sure whats causing the problem, so any help or suggestions would be greatly appreciated.</p>
  
  <p>Here is the code that is used to define/build the tree panel. I hope its not too horrible.</p>
  
  <pre><code>siteTree = Ext.extend(Ext.tree.TreePanel,{
          constructor : function(config){
              siteTree.superclass.constructor.call(this, config);
          },
          onContextMenu: function(n,e){
          if (!this.contextMenu){
              console.log('treeContextMenu',n,e);
  
              if (n.parentNode.id == 'treeroot'){
                  var menuitems = [{text:'Add Child',id:'child'}];
              } else {
                  var menuitems = 
                          [{text:'Add Child',id:'child'},
                           {text:'Add Above',id:'above'},
                           {text:'Add Below',id:'below'}];
              }
  
              this.contextMenu = new Ext.menu.Menu({
                  id:'treeContextMenu',
                  defaults :{
                      handler : treeContextClick,
                      fqResourceURL : n.id
                  },
                  items : menuitems
              });
          }
          var xy = e.getXY();
          this.contextMenu.showAt(xy);
      }           
  });
  
  var treePanel = new siteTree({
      id: 'tree-panel',
      title : 'Site Tree',
      region : 'center',
      height : 300,
      minSize: 150,
      autoScroll: true,
  
      // tree-specific configs:
      rootVisible: false,
      lines: false,
      singleExpand: true,
      useArrows: true,
  
      dataUrl:'admin.page.getSiteTreeChildren?'+queryString,
      root: {
          id: 'treeroot',
          nodeType: 'async',
          text: 'nowt here',
          draggable: false
      },
      listeners:{
          contextmenu: this.onContextMenu
      }
  });
  </code></pre>
  
  <p>As a total aside; Is there a better way to do this in my context menu function?</p>
  
  <blockquote>
    <p>if (n.parentNode.id == 'treeroot') {
    Basically, if the clicked node is the top level I only want to give the user an add Child option, not add above/below.</p>
  </blockquote>
  
  <p>Thanks in advance for your help</p>