如何正确销毁CKEditor实例? [英] How to properly destroy CKEditor instance?

查看:150
本文介绍了如何正确销毁CKEditor实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个非常简单的页面上运行CKeditor 3.4。我有一个问题(有时),当我调用document.main_form.submit()时,它不会发送textarea的内容。经过一些阅读,听起来像CKeditor没有正确破坏。我在保存表单之前尝试手动销毁它,但无法调用它。奇怪的是,它有时会起作用,但不会起作用。我在Chrome上,所以可能会搞砸事情,但在Firefox中也会发生同样的事情。

I am running CKeditor 3.4 on a pretty simple page. I am having a problem (sometimes) where when I call document.main_form.submit(), it will not send along the contents of the textarea. After some reading, it sounds like CKeditor is not destroying properly. I tried to manually destroy it before I save the form, but wasn't able to call it. The weird thing is, it works sometimes, but not others. I'm on Chrome, so that may be screwing with things, but the same thing happens in Firefox.

如何正确销毁CKeditor以便它始终发送POST中的textarea数据。谢谢!

How can I properly destroy the CKeditor so that it always sends the textarea data in POST. Thanks!

推荐答案

我遇到了这个问题。多么痛苦。

I had this problem. What a pain.

要正确销毁编辑器实例,请尝试

To properly destroy the editor instance, try

if (CKEDITOR.instances.myInstanceName) CKEDITOR.instances.myInstanceName.destroy();

来自文档这里

我通过将编辑器的内容分配给a来解决了缺少的内容问题回发之前的隐藏字段。我正在使用ASP.Net,但它应该普遍适用。

I solved the missing content issue by assigning the contents of the editor to a hidden field prior to postback. I'm using ASP.Net, but it should work universally.

在提交按钮的客户端点击处理程序中,调用

in the client-side click handler of the submit button, call

if (CKEDITOR.instances.myInstanceName)
    document.getElementById('hiddenField').value = CKEDITOR.instances.getData();

这篇关于如何正确销毁CKEditor实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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