CKEditor将空内容提交到表单。 [英] CKEditor submitting empty content to the form.

查看:620
本文介绍了CKEditor将空内容提交到表单。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始使用CKEditor v3几个星期前使用它在一个php project.i've一直使用它与jquery(使用jquery适配器)和所有这些,而使用$ .ajax(因为无法处理错误当使用jquery形式)提交和我认为一切都是好的。

I've started using CKEditor v3 few weeks ago.using it in a php project.i've been using it with jquery (using jquery adapter) and all this while using $.ajax (because can't handle for errors when using jquery form) to submit and i thought everything was alright .

所以这里弹出一个案例,我需要使用正常表单机制来提交ckeditor内容和表单的所有其他信息。

令我惊讶的是,内容是空的,所以我开始google,显然这是一个已知的问题。
我没有看到任何东西,可以让我将我的内容发布到PHP的一面。所以我想出了一个解决方法。

So here pops up a case where i need to use normal form mechanism to submit the ckeditor content and all the other information of the form.
To my surprise the content was empty so i started google and apparently it's a known issue. i haven't seen any thing YET that could let me post my content to php side. so i've come up with a workaround.

我知道onclick会始终在onsubmit之前触发,所以我写了这个。

I know onclick will always fire before the onsubmit so i've written this.

function returntoSubmit(){
    myForm = document.forms[0];
    myForm.elements["content"].value = $("#content").val();// note that the textarea name and id are all the same "content"

}

// html here 
 <input type="submit" value="Save" onclick="returntoSubmit()" />

这对我有用。但是真的有点不舒服,更好的方法来解决这个问题?

that does the work for me.But truly and a little uncomfortable with this, isn't there any better method to solve this issue?

谢谢

推荐答案

m运行一个大的应用程序与一些讨厌的遗留代码,需要一个工作在整个应用程序尽可能非侵入性。在我的情况下,不可能单独听每个页面上的提交,即使我偶尔有竞争条件,提交仍然发生之前,单击事件代码有机会做它的事情。在全局范围的页面加载之后运行时,以下似乎为我做的伎俩:

I'm running a large application with some nasty legacy code and needed something that worked across the whole app as non-intrusively as possible. In my case it wasn't feasible to listen for submits on each page individually, and even when I did I occasionally had race conditions where the submit still occurred before the click event code had a chance to do it's thing. The following seems to do the trick for me when ran after page load at a global scope:

for(var i in CKEDITOR.instances) {
  CKEDITOR.instances[i].on('blur', function() { this.updateElement(); });
}

这篇关于CKEditor将空内容提交到表单。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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