使用jQuery从CKEditor的iframe抓取内容 [英] Using jQuery to grab the content from CKEditor's iframe

查看:1012
本文介绍了使用jQuery从CKEditor的iframe抓取内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的CMS,使用 CKEditor *(FCKEditor v3)用于编辑内容。我还在使用 jQuery验证 插件在基于AJAX的提交之前检查所有字段的错误。我正在使用 serialize() 函数传递数据到PHP后端。

I have a custom-written CMS that uses CKEditor *(FCKEditor v3) for editing content. I'm also using the jQuery Validation plugin to check all fields for error prior to AJAX-based submission. I'm using the serialize() function to passing the data to the PHP backend.

问题是,serialize设法正确地获取所有字段,除了在CKEditor中输入的实际内容。像所有其他所见即所得编辑器一样,这一个也覆盖了现有文本框上的iframe。并且serialize忽略iframe并且只看到内容的文本框,当然,它不会找到,因此返回一个空白的内容正文。

Problem is, serialize manages to grab all fields correctly, except for the actual content typed in CKEditor. Like every other WYSIWYG editor, this one too overlays an iframe over an existing textbox. And serialize ignores the iframe and looks only into the textbox for content, which, of course, it doesn't find, thus returning a blank content body.

我的做法是在CKEditor的 onchange 事件上创建一个钩子并同时更新文本框( CKEDITOR.instances。[textboxname] .getData() 返回内容)或某个其他隐藏字段。

My approach to this is to create a hook onto the onchange event of CKEditor and concurrently update the textbox (CKEDITOR.instances.[textboxname].getData() returns the content) or some other hidden field with any changes made in the editor.

然而,由于CKEditor仍然处于beta阶段,严重缺乏文档,我找不到一个合适的API调用来让我这样做。

However, since CKEditor is still in it's beta stage and severely lacks documentation, I can't find a suitable API call that'll enable me to do so.

有没有人知道如何解决这个问题?

Does anyone have any idea on how to go about this?

推荐答案

p>另一个通用的解决方案是,当您尝试提交表单

Another generic solutions to this would be to run the following whenever you try to submit the form

for ( instance in CKEDITOR.instances )
            CKEDITOR.instances[instance].updateElement();

这将强制表单中的所有CKEDITOR实例更新其各自的字段

This will force all CKEDITOR instances in the form to update their respective fields

这篇关于使用jQuery从CKEditor的iframe抓取内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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