I'm doing something that I think is fairly standard :
In an Ajax application, I have dynamically create an editor by
a) dynamically adding a textarea to the DOM. The id of the textarea is stored in a variable called editField
b) I wrap TinyMCE around it like this :
tinyMCE.execCommand("mceAddControl", false, jq(editField).attr('id'));
c) I fire off an ajax call to the server to get the data to be edited, and in the callback I want to put it into the editor.
tinyMCE.get( jq(editField).attr('id') ).setContent(data);
However, when I get to the callback from the ajax call
tinyMCE.get( jq(editField).attr('id') )
is returning undefined.
The editor seems to be working. I can use it, I can even access it through tinyMCE.activeEditor (which happens when I try to save). But I can't get it via get at this point.
SO either :
a) tinyMCE isn't fully instantiated when the callback returns
b) something else is going on.
Any ideas how I can test this? And what do people do to solve this problem?