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

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

问题描述

我有一个使用的 CKEditor的 *(FCKEditor的v3)实现自定义编写的CMS编辑内容。我还使用了 jQuery验证 插件检查错误之前,基于AJAX的提交的所有字段。我使用的 序列化() 函数将数据传递给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.

但问题是,序列化管理,以正确地抓住所有领域,除了键入CKEditor的实际内容。像其他所见即所得的编辑器,这一个了覆盖一个iframe在现有的文本框。和序列忽略的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.

我的方法是创建一个钩子上的的onchange 的CKEditor的的事件,并同时更新文本框( 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的仍然是在它的测试阶段,严重缺乏资料,我无法找到一个合适的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?

推荐答案

另外一个通用的解决方案,这将是运行以下每当你尝试提交表单

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天全站免登陆