Combine Ajax content loader with editor

This function places 'Hello World' inside my rich text editor (TinyMCE)

      function ajaxLoad() {
      var ed = tinyMCE.get('elm1');
      ed.setContent('Hello World');
      }

This line of code places the content of test.php into an empty div
      ajax_loadContent('divID','external/info.php');

How can I combine these, so that I can place the content of test.php into the editor?

This does NOT work:
      function ajaxLoad() {
      var ed = tinyMCE.get('elm1');
      ed.setContent(ajax_loadContent(ed,'external/info.php'));
      }
edit.zip
LVL 16
hankknightAsked:
Who is Participating?
 
pellepConnect With a Mentor Commented:
Sorry, typo in the above.

Also, this assumes that you created the TinyMCE editor instance from a <div> (not a <textarea>) and the ajax_loadContent assumes an id of a <div>
function ajaxLoad() 
{
var ed = tinyMCE.get('elm1');
ajax_loadContent(ed.getElement() ,'external/info.php'); // set content on underlying div
ed.load(); //reload editor from underlying div
}

Open in new window

0
 
pellepCommented:
TinyMCE doesn't really work that way. When you initialize the editor instance, it replaces the div/textarea so you're not supposed to interact with the content outside of the tinyMCE framwork.

Try this and see if it works
 
function ajaxLoad() {
var ed = tinyMCE.get('elm1');
ajax_loadContent(ed.getElement() ,'external/info.php')); // set content on underlying div
ed.load(); //reload editor from underlying div
      }

Open in new window

0
 
hankknightAuthor Commented:
Thanks, pellep.

Your answer had two parts.

You explained that the content in the editor iframe MUST be reloaded after this is done.

And you explained that the code presumes the content is in a div, not a textarea.

I have asked a related question here:

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23898620.html
0
 
whspiderCommented:
Hi hankknight,

i am in need of the same...can u give me the link from where you got this editor....i to want to load
different values to the editor based on a select ooption uisng ajax
0
 
hankknightAuthor Commented:
whspider, I do not understand what you need.  The editor is TinyMCE.
http://tinymce.moxiecode.com/
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.