CKEditor将空内容提交到表单。

编程入门 行业动态 更新时间:2024-10-28 00:23:37
本文介绍了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将空内容提交到表单。

本文发布于:2023-10-09 17:56:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476379.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   内容   CKEditor

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!