使用 setData("hai") 后 Ckeditor 插件功能不起作用;

Ckeditor plugin functionality not working after using setData("hai");

我正在使用 ck-editor(4.4.6)。在 Ck-editor 的文本区域中,我想更新我的文本,为此我使用 setData("hai"); 文本更新正确,但一些插件功能在使用此 setData() 后不起作用; (例如,如果我重新加载它正常工作的页面,则限制多次输入)。

editorInstance.setData("test text");

Anyway first time and after reload the page it working fine.

ruby on rails with jquery things are I'm using.

我该如何解决这个问题?

我不知道 ck-editor(4.4.6),但我可以给你一个解决方法。您必须根据您的 parent class 使用。第一次它工作是因为它是相同的,但之后它没有找到 class/your 特定的 term/attribute。所以你必须通过调用 parent class/id 和你的 activity 来使用。

设置数据后需要调用update element函数,这实际上是在字段中设置值。 而且,您还需要指定文本区域的 ID,如下所示。

CKEDITOR.instances.id_of_textarea.setData('hai');
CKEDITOR.instances.id_of_textarea.updateElement();

最后,我得到了答案而不是设置数据我只是将我的内容添加到 CKEditor 文本区域作为 link 这工作正常:

$('#cke_editor1 iframe').contents().find('body').html("Your text");