[英]ckeditor - adding more editors to textareas
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.. 并且在开始时,它仅广告1个文本区域,然后ck编辑器起作用。.但是,如果我添加更多这些,它将不起作用。
Hopefully you people got an answer like always! 希望大家能像往常一样得到答案!
Fiddle: http://jsfiddle.net/BpvQ5/ 小提琴: http : //jsfiddle.net/BpvQ5/
Every time you create dinamically a new textarea, need to call CKEDITOR.replace
to replace this textarea as an editor: 每次您动态创建一个新的文本区域时,都需要调用
CKEDITOR.replace
来替换该文本区域作为编辑器:
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. 无论如何,您的代码都会失败,因为您正在使用旧的ID创建新的textarea。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.