Sunday, September 23, 2012

tinymce mceRemoveControl NS_ERROR_UNEXPECTED: Component returned failure code

Im not sure if its considered a bug, but this is annoying for me.
When i ran mceRemoveControl command to remove a already destroyed tinymce on a textarea,

After googling around with not much result, ive decided to dig into the source code ,
and finally found a solution.
Instead of calling directly mceRemoveControl, call this tinyMCE.remove(tinyMCE.getInstanceById()):

var oInstance = tinyMCE.getInstanceById("txtContent");
if (oInstance) {
  if (oInstance.isHidden()) tinyMCE.remove(oInstance);
  tinyMCE.execCommand('mceRemoveControl', true, "txtContent");
tinyMCE.execCommand('mceAddControl', true, "txtContent");




Connie C said...

Thank you! I ran into this problem today -- and this fixed it.

James Tt said...

great ;)

Muthukumar G said...

Awesome!.....Really Great...Thank you

Alexander Voronin said...

Thank you!

binnoor said...

Excellent job.

bul said...

You, sir, deserve a trophy! Thank you!

bul said...

You, sir, deserve a trophy! Thank you!