Topic: TinyMCE causing exceptions when initialized second time in one page
Nov 3, 2009: update below
In short:
When I attach an editor to a dynamically created textarea the second time, it doesn't load the contents of the textarea, and causes a bunch of exceptions.
In detail:
My CMS allows the user to instantiate TinyMCE multiple times on one page, but only once at a time. When the user chooses to "Edit > Contents", a javascript file and html file are loaded via AJAX (using the jQuery library). The newly loaded Javascript file contains code that initializes an editor instance, and attaches it to a textarea that is contained in the newly loaded html file. I've got other Javascript code that populates the content of the textarea, before the editor is attached to it. If it matters, the tiny_mce.js library is only loaded once on page load. It isn't loaded dynamically.
The first time I initialize the editor, everything works perfectly. I can click all the editor buttons, the editor contains the appropriate content, I can retrieve the content from it (using getContent()), and so on.
When I close the modal box that contains the editor, I call various removal & deletion commands in hopes of completely obliterating any occurrence of the editor:
mce.remove(); //mce is the editor
tinyMCE.execCommand('mceRemoveControl', true, 'vik-content-field'); //vik-content-field is the id of the textarea it gets attached to
delete mce;I'm guessing none of those fully work, because poop hits the fan the next time I try to "Edit > Contents".
The second time, the editor loads up, but the content isn't there. If I try to edit the contents via the paste-as-text button, or the table button (I can't click inside the editor to type), I get a Javascript exception.
I'm using the latest version of TinyMCE which I downloaded today. I've only been testing in FF 3.5.
Absolutely any insight would be appreciated. I thought I'd move my CMS from FCKEditor to TinyMCE, but it's taken me 3 hours (so far) on this one problem.
Last edited by quasipickle (2009-11-04 06:37:28)

