CKEditor getEditor()错误,如何解决?

Bip*_*Bip 13 html javascript asp.net ckeditor

<textarea cols="50" id="txt" contenteditable="true" name="editor1" runat="server" rows="10"></textarea>
<script type="text/javascript" src="css-js/ckeditor.js"></script>
<script type="text/javascript">
  CKEDITOR.replace('txt', {                    
  });       
</script>
Run Code Online (Sandbox Code Playgroud)

我在js上得到这个错误:

TypeError:无法调用'getEditor'undefined 方法

ole*_*leq 16

First of all, contenteditable="true" tag is totally invalid and obsolete in your case. Such attribute is relevant for inline instances only and, as <textarea> is not (content)editable, you don't need it.

无论如何,(即使有错误)你的代码对我来说就像一个魅力(小提琴).作为一个解释,你看到的错误是在没有id传递给的元素时产生的CKEDITOR.replace(),即:

<textarea id="foo"></textarea>
<script type="text/javascript">
     CKEDITOR.replace( 'bar' ); // <textarea> is #foo, error will be thrown
</script>
Run Code Online (Sandbox Code Playgroud)

确保你的DOM有效并<textarea>CKEDITOR.replace调用时存在(工作异步?).


jay*_*vkv 3

使用

CKEDITOR.appendTo( 'txt' ); for DOM elements

CKEDITOR.replace( 'textarea' ); for textarea
Run Code Online (Sandbox Code Playgroud)

好吧,伙计也试试这个

函数appendTo和replace都位于themedui.js文件中

尝试单独添加,这是链接

http://docs.ckeditor.com/source/ckeditor.html#CKEDITOR