具有所见即所得问题的动态表单

发布于 2024-09-09 10:20:35 字数 519 浏览 1 评论 0原文

我在使用所见即所得编辑器时遇到动态表单问题。我正在使用FCKEditor(我被迫)。

从一开始,我在 Fencybox 中创建了一个可爱的表单,并且工作正常。我只有一个小问题,表单没有发送任何值。根据文档链接文本,一切都已正确实现。

我试图通过以下方式获取编辑器内容:

var comment = $("#comment").val();

不工作,想知道为什么。您有什么建议吗?

编辑 警报(评论);什么也不返回。但是当我输入:

success: function(html){
    alert(comment);
}

它工作正常。有什么想法吗?

问候, 汤姆

I'm having issues with dynamic form with wysiwyg editor. I'm using FCKEditor (I'm forced to).

From the begining, I create a cute form in Fencybox, working correctly. I'm having only one small isssue, form is not sending any value. According to documentation link text everything is implemented correctly.

I'm trying to get editor content by:

var comment = $("#comment").val();

Not working, wondering why. Do you have any suggestions?

Edit
alert(comment); return nothing. But when I put in:

success: function(html){
    alert(comment);
}

it works correctly. Any ideas?

Regards,
Tom

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

荒路情人 2024-09-16 10:20:35

使用 CKEditor JavaScript API 检索 HTML 值:

var comment = FCKeditorAPI.GetInstance('comment_body').GetHTML();

Use the CKEditor JavaScript API to retrieve the HTML value:

var comment = FCKeditorAPI.GetInstance('comment_body').GetHTML();
不知在何时 2024-09-16 10:20:35

我想我明白你想要什么...你那里的 jQuery 选择器不会返回任何内容,因为你试图获取表单的值(#comment 是你的表单的 id

)编辑器内容实际上位于 iframe 或 textarea 内部,具体取决于您是否查看源代码...尝试以下操作:

var content = ($('textarea.cke_source').length) ? $('textarea.cke_source').val() : $('table.cke_editor iframe').contents().find('body').html();

编辑:使用 Jon 的答案...现在我再看一次,我认为这是针对 CKEditor 而不是 FCKEditor,这很容易来混淆两者。

I think I see what you want... the jQuery selector you have there won't return anything because you are trying to get the value of the form (#comment is the id of your form)

The editor content is actually inside of an iframe or textarea depending if you are looking at the source... try this:

var content = ($('textarea.cke_source').length) ? $('textarea.cke_source').val() : $('table.cke_editor iframe').contents().find('body').html();

Edit: Use Jon's answer... now that I look again, I think this was for CKEditor and not FCKEditor, it's easy to confuse the two.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文