1

i insert many texarea's, and teaxarea's with tiny mce (WYSIWYG). But when i Insert this teaxarea's from this function Tiny MCS don't work. Why?

Thanks

$(document).ready(function(){
  $("#InsertNew").click(function() {
   $('<textarea id = "tinyMCE"></textarea>').appendTo($('#textBody'));
  });
 });
3
  • 1
    What does your .tinyMCE script look like? The one that's running based on that selector? Also you should use a class here, IDs need to be unique. Commented Aug 9, 2010 at 12:34
  • you've only tagged half of your questions as answered. I hope that doesn't mean you are not getting useful help here. Commented Aug 9, 2010 at 12:44
  • Could you post more of your code? Commented Aug 9, 2010 at 13:28

4 Answers 4

3

Well your code looks like this:

<textarea id="tinyMCE"></textarea>

So what is happening here? You just add a textarea with the ID="tinyMCE" but no behaviour is added to the TextArea.

In jQuery I would expect at least the following:

<textarea class="tinyMCE"></textarea>

or event better:

$('<textarea></textarea>').tinyMCE().appendTo($('#textBody'));   

EDIT:

You might try something like this...

$('<textarea id="UniqueId"></textarea>').tinyMCE().appendTo($('#textBody'));   
tinyMCE.init({
  mode : "exact",
  elements : "UniqueId"
});

On the tinyMCE-Formus is already a diskussion going on...

http://tinymce.moxiecode.com/punbb/viewtopic.php?id=15477

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, but i change tiny mce parameter and now work with: <textarea class = "tinyMCE"></textarea> (if i write in html). But when i put this code in my jQuery function still dos't work
0

you mentioned you are using many text areas, the place ur trying to append to is #textBody (an id). If you are not aware, you can only have one instance of an ID per page. Instead use a classes: class="textBody" in your html then try:

$('<textarea id = "tinyMCE"></textarea>').appendTo('.textBody');

1 Comment

Well spot, but the problem is actually id="tinyMCE".
0

Most likely, because TinyMCE has an initializer that scans the document looking for textareas and applies some magic on the ones that finds. Whatever you add later won't inherit this. You have to either:

  1. Re-run the TinyMCE initializer on every new item
  2. Configure TinyMCE to detect new areas

Since TinyMCE is not a jQuery plugin, I suppose you can only do #1.

2 Comments

Thanks, but how impossible re-run script?
How do you run it the first time?
0

I think this forum post is what you are looking for.

You will need to use the jQuery live method and a trick explained at the link above.

Comments

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.