?
Solved

Combine Ajax content loader with editor

Posted on 2008-11-12
5
Medium Priority
?
428 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:hankknight
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:pellep
ID: 22939751
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
 
LVL 4

Accepted Solution

by:
pellep earned 2000 total points
ID: 22939773
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
 
LVL 16

Author Comment

by:hankknight
ID: 22941037
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
 

Expert Comment

by:whspider
ID: 24383453
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
 
LVL 16

Author Comment

by:hankknight
ID: 24386498
whspider, I do not understand what you need.  The editor is TinyMCE.
http://tinymce.moxiecode.com/
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question