title: ExtJS 4.1: unload event
body: <p>I am working with ext js 4.1. I am developing an application that have to support IE9, the latest Firefox, the latest Chrome and Safari.</p>
  
  <p>I need to show an alert message when the user wants to leave the if there are some data that is pending to submit.</p>
  
  <p>I did the following using raw Javascript:</p>
  
  <pre><code>window.onbeforeunload=function(){
      if (Ext.getStore('LocalChangesStore')){
          if (Ext.getStore('LocalChangesStore').getCount() &gt; 0) {
              return 'Your changes are be lost.'; 
          } 
      }
  };
  </code></pre>
  
  <p>I am wondering if that would be possible with ext js. I saw the following function:</p>
  
  <p><em>app.js:</em></p>
  
  <pre><code>EventManager.onWindowUnload( function(){
      if (Ext.getStore('LocalChangesStore')){
          if (Ext.getStore('LocalChangesStore').getCount() &gt; 0) {
              return 'Your changes are be lost.'; 
          } 
      }        
      }, this
  );
  </code></pre>
  
  <p>but it did not work.</p>
  
  <p>Can somebody let me know which would be the best approach to solve this issue? </p>