title: tinymce suddenly r is not constructor q.getwin is undefined
body: <p>I have been using an ancient version of tinyMCE for 10 years now with no problems. majorVersion:"3",minorVersion:"2.7",releaseDate:"2009-09-22" Since there were no problems and it did what I wanted I never bothered upgrading to a newer release.  Implementing a newer version would require changing every script which uses tinyMCE at the very least to reference the new file name tinymce.min.js. But suddenly I am getting the following errors when I call tinMCE.init and none of the textareas are converted.  These errors appear only in the log.  A try/catch around the call to init does not report the problems.  I have been forced to throw try/catch around every call to tinyMCE because the failure to initialize the textareas means I have to revert to obtaining the value of the elements from the value attribute of the textarea:</p>
  
  <pre><code>TypeError: r is not a constructor[Learn More] tiny_mce.js:1:118759
  init
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:118759
  r/&lt;
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:118589
  loadQueue/&lt;
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:84151
  allDone
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:84641
  loadScripts
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:85295
  loadQueue
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:84094
  r
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:118551
  render
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:118601
  init/&lt;/&lt;
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:111552
  each
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:1547   
  init/&lt;
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:111297
  g
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:53537
  _pageInit/&lt;
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:55059
  each
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:1547
  _pageInit
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:55037
  _wait/&lt;
  https://localhost/tinymce/jscripts/tiny_mce/tiny_mce.js:1:55590
  
  TypeError: q.getWin(...) is undefined[Learn More] tiny_mce.js:1:127070 
  </code></pre>
  
  <p>I am puzzled because I have not changed any of the lines of Javascript that invoke tinyMCE.  However I know the problem must be in my code because I get the same gibberish errors on both Firefox and Chrome.  For example the unmodified call to init is:</p>
  
  <pre><code>tinyMCE.init({
      mode            : "textareas",
      theme           : "advanced",
      plugins         : "spellchecker,advhr,preview", 
  
      // Theme options - button# indicates the row# only
      theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,fontselect,fontsizeselect,formatselect",
      theme_advanced_buttons2 : "cut,copy,paste,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,|,forecolor,backcolor",
      theme_advanced_buttons3 : "",
      theme_advanced_toolbar_location : "top",
      theme_advanced_toolbar_align : "left",
      theme_advanced_statusbar_location : "bottom",
      theme_advanced_resizing : true,
      forced_root_block   : false,
      forced_root_block   : false,
      content_css     : "/styles.css",
      onchange_callback   : "changeOccupation",
      editor_deselector   : "mceNoEditor"
  });
  </code></pre>
  
  <p>I have not changed even a single line of code related to tinyMCE. I am not using any other imported code except Google maps, which I last changed over a month ago because of Google's tightening of the license conditions.  The last change I made to my implementation prior to the problem arising on both Firefox and Chrome was a change to one of my personal libraries which displays dialogs related to entering place names. The library is <a href="https://www.jamescobban.net/jscripts/locationCommon.js" rel="nofollow noreferrer">https://www.jamescobban.net/jscripts/locationCommon.js</a> . The layout of these dialogs is controlled by HTML templates in <a href="https://www.jamescobban.net/templates/LocationDialogsen.html" rel="nofollow noreferrer">https://www.jamescobban.net/templates/LocationDialogsen.html</a>.  To simplify adding this functionality to a PHP script on my site I changed locationCommon.js so it appends contents of the template file onto the body of the page by document.body.innerHTML += text;  You can see the code that does this near the top of locationCommon.js.  This avoids the need to manually add the common template information into every script which calls the functions in locationCommon.js and also added I18N support for the dialogs.</p>
  
  <p>I just do not see why any of the completely unrelated changes I have made to my implementation would suddenly cause tinyMCE to fail.</p>
  
  <p>Unfortunately all of the scripts on my site which demonstrate the problem require that the user be signed in as a registered user and specifically granted permission to update the requested record. For example <a href="https://www.jamescobban.net/FamilyTree/editEvent.php?idir=117083&amp;rownum=&amp;ider=0&amp;type=30&amp;idet=47" rel="nofollow noreferrer">https://www.jamescobban.net/FamilyTree/editEvent.php?idir=117083&amp;rownum=&amp;ider=0&amp;type=30&amp;idet=47</a>.  And those scripts which do permit casual visitors to enter data using tinyMCE do not demonstrate the problem.  For example: <a href="https://www.jamescobban.net/BlogPost.php?table=Blogs&amp;blogid=297" rel="nofollow noreferrer">https://www.jamescobban.net/BlogPost.php?table=Blogs&amp;blogid=297</a></p>
  
  <p>I tried modifying one of the failing scripts to use a more recent version of tinyMCE (4.2.7) but that failed, demonstrating precisely the reasons I am sticking with the old version, with:</p>
  
  <pre><code>Loading failed for the &lt;script&gt; with source “https://localhost/jscripts   /tiny_mce/js/tinymce/themes/advanced/theme.min.js”. editEvent.php:1:1
  Loading failed for the &lt;script&gt; with source “https://localhost/jscripts/tiny_mce/js/tinymce/plugins/advhr/plugin.min.js”. editEvent.php:1:1
  Failed to load: https://localhost/jscripts/tiny_mce/js/tinymce/themes/advanced/theme.min.js tinymce.min.js:4:3508
  Failed to load: https://localhost/jscripts/tiny_mce/js/tinymce/plugins/advhr/plugin.min.js tinymce.min.js:4:3508
  TypeError: tinyMCE.get(...) is null[Learn More]
  </code></pre>
  
  <p>I backed out the code which added the templates to the page body and confirmed that was what triggered the failure of tinyMCE. The problem that leaves is that I still need to make those templates available to the locationCommon.js script.  I don't want to load the templates as text because the library routines for displaying dialogs all expect the template to be HTML.  I have tried loading them as XML, but that means that I cannot locate the templates using any of the HTML DOM methods, in particular document.getElementById.  So I have to kluge up the XML DOM to simulate the HTML DOM methods. In particular the code was expecting to be able to use the interface for class HtmlFormElement, including the attributes id, name, elements, and that each of the input elements in the form are available as attributes of the form element under the value of their name attribute. So I now have a whole mess of code whose sole purpose is to get around the fact that tinyMCE coughs its cookies if somebody adds text to the body section!  I would really appreciate it if someone could explain to me why I have to do all this extra work.</p>