title: TinyMCE UndoManager. Get event to fire
body: <p>I have made a webform that uses a TinyMCE editor. When the user clicks on a link to leave the page, I want a message to be displayed if he still has unsaved changes. For this, I was thinking of using the TinyMCE undoManager, <a href="http://www.tinymce.com/wiki.php/API3:class.tinymce.UndoManager" rel="nofollow">http://www.tinymce.com/wiki.php/API3:class.tinymce.UndoManager</a></p>
  
  <p>Essentially, I want the events onAdd, onUndo, OnRedo to fire. I will then keep track of the number of changes (if any) since the last save. But how do I get them to fire? Where do I set them up?</p>
  
  <p>Also, it would be nice to have access to the hasUndo method in the rest of my javascript code. Again, not sure where to initiate this?</p>
  
  <p>Not sure if it matters, but I'm using Django.</p>
  
  <p>Edit: I have tried</p>
  
  <pre><code>tinyMCE.init({
      ...,
      setup : function(ed) {        
          ed.UndoManager.onAdd(function(ed) {   
          ed.windowManager.alert('added.');  
          });
      }      
  });
  </code></pre>
  
  <p>This gives me an error: Unable to get value of the property 'onAdd': object is null or undefined</p>