title: How to remove a listener before an event takes place?
body: <p>My question is similar to this one: <a href="https://stackoverflow.com/questions/16101853/how-to-prevent-itemclick-event-on-check-change-in-ext-js-tree">How to prevent itemclick event on check change in Ext Js Tree</a>.</p>
  
  <p>However, it does not provide a solution for my problem. So, my question is: how can I remove a listener before an event takes place? The problem is that I have three listeners in my tree, and on <code>checkchange</code> I want to prevent the <code>itemclick</code> event. But everything executes in an unexpected order. The code is:</p>
  
  <pre><code>checkchange:function(node,check){                           
    alert("1");
  },
  itemclick:function(view,rec,item,index,eventObj){
    alert("2");
  },
  render:function(){
    Ext.getCmp('mytree').on('checkchange',function(node,check){
      alert("0");
      Ext.getCmp('mytree').removeListener('itemclick',this);
    });
  }
  </code></pre>
  
  <p>When I check a node in my tree, I first see <code>alert(2)</code>, then <code>alert(1)</code> and only then <code>alert(0)</code>. So, the code which should remove the listener happens at the very end and I want the opposite.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I do not want to completely remove the <code>itemclick</code> event. The more appropriate word is to "stop" an event, to prevent it from happening.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>The solution is to do e.getTarget() check inside the itemclick event. So, my code inside the <code>itemclick</code> event now looks like this:</p>
  
  <pre><code>itemclick:function(view, record, item, index, e, eOpts){
    if(e.getTarget('span',1,true)){
       // all other code which should take place in case
       // itemclick event does not come from checkbox element
    }
  }
  </code></pre>