TinyMCE: repeated initialisation causing textarea not updating

I just noticed this problem in the interop database project. Thought it was my new code that messed up but it was actually there all the time!!!

Symptom:

  • If I repeatedly edit the text using the same tinyMCE instance, after the second time. The textarea fails to be updated with the text…. as a result $(“#textarea_id”).val() will give you old value!!!!

Fix:

  • Having realised that my code initTinyMCE every time someone clicks the edit button. I came up with this solution:

function initTinyMce(iid)
{
if (typeof(tinyMCE) != "undefined") // ="object" means alreaedy init'd
{
// now check if this iid is already init'd
if ($.inArray($("#issuesField" + iid).tinymce(), tinyMCE.editors) == 0) // found, this one already init'd
return; // to avoid multi-init causing textarea not updated problem
}
// my code to actually init the tinyMCE instance

It works!

Leave a Reply

Your email address will not be published. Required fields are marked *

www.000webhost.com