Javascript CKEditor getEditor()错误,如何修复? CKEDITOR.replace('txt',{ });
我在js上犯了这样的错误: TypeError:无法调用未定义的方法Javascript CKEditor getEditor()错误,如何修复? CKEDITOR.replace('txt',{ });,javascript,html,asp.net,ckeditor,Javascript,Html,Asp.net,Ckeditor,我在js上犯了这样的错误: TypeError:无法调用未定义的方法'getEditor' 使用 好的,伙计,也试试这个 appendTo和replace函数都位于themedui.js文件中 尝试单独添加它,这里是链接 首先,contenteditable=“true”标记在您的情况下是完全无效和过时的。该属性与相关,并且由于不可(内容)编辑 无论如何,(即使有bug)你的代码对我来说就像一个符咒()。作为解释,您看到的错误是在没有传递给CKEDITOR.replace()的id元素时产生的,
'getEditor'
使用
好的,伙计,也试试这个
appendTo和replace函数都位于themedui.js文件中
尝试单独添加它,这里是链接
首先,
contenteditable=“true”
标记在您的情况下是完全无效和过时的。该属性与相关,并且由于
不可(内容)编辑
无论如何,(即使有bug)你的代码对我来说就像一个符咒()。作为解释,您看到的错误是在没有传递给CKEDITOR.replace()
的id
元素时产生的,即:
<textarea id="foo"></textarea>
<script type="text/javascript">
CKEDITOR.replace( 'bar' ); // <textarea> is #foo, error will be thrown
</script>
CKEDITOR.replace('bar');//如果为#foo,将抛出错误
当调用
CKEDITOR.replace
(异步工作?)时,请确保您的DOM有效并且存在
。如果您只是想摆脱它,请使用
try{CKEDITOR.replace('body')}catch{}
这将导致CKEDITOR在您希望的位置打开问题可能包括:
<script src="{{ asset('js/app.js') }}" defer></script>
尝试移除它。这可以解决您的问题我有一个类似的问题,并通过执行以下操作对其进行排序
<script src="/vendor/unisharp/laravel-ckeditor/ckeditor.js"></script>
<script>
if($("textarea").length > 0){
CKEDITOR.replace( 'ckeditor' );
}
</script>
如果($(“textarea”).length>0){
CKEDITOR.replace('CKEDITOR');
}
这是正确的方法(我通过检查django admin找到了这个方法)
- 上述配置适用于模态形式,但也适用于正常形式
<script src="/vendor/unisharp/laravel-ckeditor/ckeditor.js"></script>
<script>
if(document.getElementsByTagName('textarea').length > 0){
CKEDITOR.replace( 'article-ckeditor' );
}
</script>
if(document.getElementsByTagName('textarea')。长度>0){
CKEDITOR.替换('article CKEDITOR');
}
您尝试了哪些浏览器?在多个浏览器上试用。@AmirNoori Google Chrome版本:29.0.1547.76,我也试过firefox和ie 10,但不起作用。试着在一个空的html页面中加载ckeditor并再次使用它,看看是否有任何错误。使用ckeditor.appendTo('txt');对于Div元素,我尝试了这两种方法,但都不起作用,我得到了相同的错误。感谢回答中的代码不起作用,因为textarea没有ID。解决方案是#foo,将抛出错误
这应该是答案,因为它实际上纠正了OP问题。其他答案是解释和建议。不是修复。
var textAreaEl = document.getElementById("id_html_txt")
var textAreadData = textAreaEl.dataset.config
var textEditor = CKEDITOR.replace(textAreaEl, textAreadData);
textEditor.insertHtml(textAreaEl)
<script src="/vendor/unisharp/laravel-ckeditor/ckeditor.js"></script>
<script>
if(document.getElementsByTagName('textarea').length > 0){
CKEDITOR.replace( 'article-ckeditor' );
}
</script>