1

I'm using jQuery ajax function to dynamically load content from another file. I want to add TinyMCE editor to my page this way. Link to tiny_mce.js file and the editor initialization script should be included in the dynamically loaded file. The problem is that it's not working for me.

Here is simple example of what I've want to do: http://www.darrarski.pl/TinyMCE_ajax/index.html

Here is file that is loaded via ajax: http://www.darrarski.pl/TinyMCE_ajax/editor.html

If you open the second file directly in your browser, TinyMCE editor is working with no problem.

Using Firebug console, you can see that tiny_mce.js is being successfully loaded. I've also added console.debug() is several places, so you can see, that script from ajax loaded file (editor.html) is being executed correctly and there are no errors. The link to the jQuery library in the second file is included only for testing reasons (so it will work when you access this file directly in your browser) and it's not necessary when loading editor via ajax.

Please, help me solving this issue.

Update: I've found another WYSIWYG editor, that works the way I want, but it's not well documented and I'm afraid of using it because of lack of options that TinyMCE has. But maybe it will help someone with marking TinyMCE ajax initialization possible:

http://www.darrarski.pl/elRTE_ajax/index.html

Anyway, this is exactly behaviour that I want to achieve using TinyMCE.

1 Answer 1

1

Problem here is that you are loading not a html element into the div named "content", but a whole page. This does not work. What you need to do is to insert a html element only.

I worked with your code and when your editor.html contains the following it works:

<textarea cols="50" rows="5"  id="editor" name="editor">test content</textarea>
<script type="text/javascript">
        tinyMCE.init({
            mode : "textareas",
            theme : "advanced"
        });
</script>
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, it finally get working. But is there a way to load tiny_mce.js via ajax, from editor.html file? That's the way I would like to use it.
yes, that is possible, but you will have to eval the scriot on the main page in order to make it work i think

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.