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

查看:1837
本文介绍了如何正确销毁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,以便它总是发送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();

从文档此处

我通过将编辑器的内容分配给在回发之前的隐藏字段。我在使用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天全站免登陆