title: Can't seem to close tinymce 4 popup from a custom plugin
body: <p>I have created a custom plugin inside of tinyMCE 4. It pops up a modal window and displays images in a said directory. You pick the image, then it adds it to the content and closes the popup. I have it inserting the image into the content, but I can't seem to close the popup. I've tried many different ways and none of them work.</p>
  
  <p>One of the errors I get is:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'win' of undefined
  </code></pre>
  
  <p>That's happening with the current code which follows:</p>
  
  <p><strong>Plugin:</strong></p>
  
  <pre><code>tinymce.PluginManager.add('imageuploads', function(editor, url) {
  // Add a button that opens a window
  editor.addButton('imageuploads', {
      text: 'Insert Image',
      icon: false,
      onclick: function() {
          // Open window
          editor.windowManager.open({
              title: "Insert Uploaded Image",
              url: 'insertimage.php',
              width: 700,
              height: 600,
              inline: true,
              close_previous: "yes"
          });
      }
  });
  });
  </code></pre>
  
  <p><strong>Plugin File:</strong></p>
  
  <pre><code>$(document).ready(function(){
      $('#submit-image-url').bind('click', function(){
          var image_url = $('.image_choice:checked').val();
          var insert_url = '&lt;img src="/editor/uploads/' + image_url + '"&gt;';
  
          parent.tinymce.activeEditor.selection.setContent(insert_url);
          parent.tinymce.activeEditor.windowManager.close(this);
      });
  });
  </code></pre>
  
  <p>There is some HTML before that, but all it is is the images listed out with a radio input to determine which one is selected. Inserting works, but I can't seem to close the popup.</p>
  
  <p>Any help would be greatly appreciated! Thanks!</p>
  
  <p>The errors are coming from tinymce.js on line #22746, so the close() method is getting called. It just can't see the popup for some reason.</p>