Reputation: 697
Im trying to add some editors to the textareas
When i write
<textarea class="ckeditor" id="editor5"></textarea>
<textarea class="ckeditor" id="editor6"></textarea>
<textarea class="ckeditor" id="editor7"></textarea>
<textarea class="ckeditor" id="editor8"></textarea>
<textarea class="ckeditor" id="editor9"></textarea>
It works just as i want.. But im using this to add more textbo
message = new Array();
jQuery.fn.update_textarea = function(test) {
$("#articles_textarea").html('');
for (i=0;i<test;++i) {
if (message[i]) { $("#articles_textarea").append('<h2>askda</h2><textarea class="ckeditor" id="editor' + [i] + '"></textarea>'); }
else { message[i] = ''; $("#articles_textarea").append('<h2>askda</h2><textarea class="ckeditor" id="editor' + [i] + '"></textarea>'); }
}
}
And in the beginning it only ads 1 textarea and then the ck editor works.. But if i add more of these it won't work..
Hopefully you people got an answer like always!
Fiddle: http://jsfiddle.net/BpvQ5/
Upvotes: 0
Views: 490
Reputation: 3362
Every time you create dinamically a new textarea, need to call CKEDITOR.replace
to replace this textarea as an editor:
jQuery.fn.update_textarea = function(test)
{
$("#articles_textarea").html('');
for (i=0;i<test;++i)
{
if (message[i])
{
$("#articles_textarea").append('<h2>askda</h2><textarea class="ckeditor" id="editor' + i + '"></textarea>');
}else {
message[i] = ''; $("#articles_textarea").append('<h2>askda</h2><textarea class="ckeditor" id="editor' + i + '"></textarea>');
}
CKEDITOR.replace( 'editor' + i );
}
}
Anyway, your code fails because you are creating new textareas with the id of the olders.
Upvotes: 1