我正在尝试让 ckeditor 工作。显然它没有使用文本区域,因此提交表单时不会在编辑器中提交文本。因为我使用多态关联等。我无法创建 onsubmit 函数来获取 textarea 的值(当提交表单时)。
所以我发现了这个问题:使用 jQuery 从 CKEditor 的 iframe 中获取内容 https://stackoverflow.com/questions/924145/using-jquery-to-grab-the-content-from-ckeditors-iframe
有一些非常好的答案。那里发布的答案使文本区域保持最新。这非常好,正是我所需要的!不幸的是我无法让它工作。
有人知道为什么(例如)这不起作用吗?
我有一个文本区域(rails,但它只是转换为普通文本区域):
<%= f.text_area :body, :id => 'ckeditor', :rows => 3 %>
以及以下js:
if(CKEDITOR.instances.ckeditor ) {
CKEDITOR.remove(CKEDITOR.instances.ckeditor);
}
CKEDITOR.replace( 'ckeditor',
{
skin : 'kama',
toolbar :[['Styles', 'Format', '-', 'Bold', 'Italic', '-', 'NumberedList', 'BulletedList', 'Link']]});
CKEDITOR.instances["ckeditor"].on("instanceReady", function()
{
//set keyup event
this.document.on("keyup", CK_jQ);
//and paste event
this.document.on("paste", CK_jQ);
}
function CK_jQ()
{
CKEDITOR.instances.ckeditor.updateElement();
}
我的萤火虫中出现以下“错误”。
missing ) after argument list
[Break on this error] function CK_jQ()\n