Ck编辑器不工作后,它在innerHTML替换一个div与Ckeditor textarea [英] Ck editor is not working after putting it in innerHTML to replace a div with the Ckeditor textarea

查看:396
本文介绍了Ck编辑器不工作后,它在innerHTML替换一个div与Ckeditor textarea的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我已经被分配了一个工作,我有一个输入文本,如果有人会点击它,然后它会替换为一个textaread它启用了ckeditor。我已经启用了ckeditor的textarea,但是当我试图用启用ckeditor的textarea替换一个div,那么它只是显示一个简单的textarea没有ckeditor启用它。它是它的编码: -

today i have been assigned a work where i have an input text and if someone will click on it then it will replace it with a textaread which has ckeditor enabled on it. I already enabled the ckeditor with the textarea but when i am going trying to replace a div with the ckeditor enabled textarea then it is just showing me a simple textarea not with ckeditor enabled on it.Below is the coding for it:-

<script type="text/javascript">
function myJDFunction1()
{
document.getElementById("Hide1").innerHTML='<textarea class="ckeditor" id="typingarea2" name="typingarea2"></textarea>';
}

</script>



<div id="Hide1">
    <textarea name="Answer1" onclick="myJDFunction1()"></textarea>
</div>


推荐答案

您必须致电

CKEDITOR.replace( 'typingarea2' );

因为编辑器实例仅在加载页面时自动创建

since editor instances are created automatically (by class) only when the page is being loaded.

更好的方法是:

function myJDFunction1() {
    CKEDITOR.appendTo( 'Hide1' );
}

<div id="Hide1" onclick="myJDFunction1()">&nbsp;</div>

这篇关于Ck编辑器不工作后,它在innerHTML替换一个div与Ckeditor textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆