我在我的网站上包含了CKEditor.即使我收到这个JS错误,一切正常:
未捕获的异常:[CKEDITOR.editor]实例"simple_editor"已经存在.
下面的代码包含在PHP文件中,我在其中包含了我想要编辑器的位置.我每页只有一个编辑器实例.
<textarea class='ckeditor' id='simple_editor' name='simple_editor'>".$page_content."</textarea>";
<script type="text/javascript">
CKEDITOR.replace( 'simple_editor',
{
height: '110px',
toolbar :
[
['Link','Unlink'],
['Styles','Format','Font','FontSize'],
['Bold','Italic','Underline','Strike'],
['TextColor','BGColor'],
['NumberedList','BulletedList','Outdent','Indent']
]
});
</script>
Run Code Online (Sandbox Code Playgroud)
经过一些谷歌搜索后,我看到人们发布了一些有效的解决方案.
if (CKEDITOR.instances['simple_editor']) { delete CKEDITOR.instances['simple_editor'] };
if (CKEDITOR.instances['simple_editor']) { CKEDITOR.instances['simple_editor'].destroy(); }
Run Code Online (Sandbox Code Playgroud)
谁知道该怎么办?:S
我通过ajax获取此代码:
<script>
$(function(){
$('#responseContent').ckeditor();
});
</script>
<textarea id='responseContent'></textarea>
Run Code Online (Sandbox Code Playgroud)
它成功生成了一个CKEditor窗格,用于精美的文本编辑.
当第二次调用同一段代码时,我得到一个空白区域.奇怪的是,当我对textarea/ckeditor应该在哪里做"检查元素"时,它说:
<textarea id="responseContent" style="visibility: hidden; "></textarea>
Run Code Online (Sandbox Code Playgroud)
所以,作为我的专业黑客,我jQuery它所以是可见性:可见.CSS陷入困境,但结果看起来并没有什么不同.
你如何让ckeditor工作...一直......用ajax生成的数据?
编辑:为了清楚,我不相信这是一个CSS问题.我相信这是一个jquery/ckeditor问题.