FCKeditor firefox Ajax提交,内容为空.解决.

The editor's content is empty when submitting the editor's surrounding form by ajax. What is wrong?

This problem is caused by a missing call of the function FCK.UpdateLinkedField(). By submitting the editor's surrounding form with an ajax function the values of all form elements are collected in a javascript object (some kind of an array). At this time the value of the hidden field that usually contains the editor's html output is empty, because the editor's surrounding form wasn't submitted for real, you can call it a simulated submit. The workaround is to call the FCK.UpdateLinkedField() function before submitting the form. Either you call it directly before the ajax collect function or in the onClick attribute of the submit button. For general use, even if you have more than one FCKeditor instance, I wrote the following hack to solve the problem.

// Some Class
function MyClass()
{
this.UpdateEditorFormValue = function()
{
for ( i = 0; i < parent.frames.length; ++i )
if ( parent.frames[i].FCK )
parent.frames[i].FCK.UpdateLinkedField();
}
}
// instantiate the class
var MyObject = new MyClass();
  • Now can call this method in the onSubmit attribute of the editor's surrounding form before calling the ajax collecting function:

<form ... onSubmit="MyObject.UpdateEditorFormValue(); Ajax.Collect(); return false;">

Note: the previous syntax won't work if using VisualStudio 2005 and Atlas and IE. It will be ok to use :

<form ... onSubmit="MyObject.UpdateEditorFormValue(); return true;">

Or you'll do it in the onClick attribute of the submit button, which is also called before the onSubmit event:

<input type="submit" ... onClick="MyObject.UpdateEditorFormValue();" />
 
以上为FCKeditor官方原文。ajax提交含有FCKeditor的表单的时候。在firefox会忽略吊用FCK.UpdateLinkedField()函数。不能及时把iframe的内容赋值到隐藏表单域中。从而提交给服务器端。
解决方法就是在点击提交按钮的时候,循环遍历一下form中的iframe,并且吊用iframe.contentWindow.FCK.UpdateLinkedField()方法.

转载于:https://www.cnblogs.com/zzh/archive/2008/09/18/1293512.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值