【问题标题】:jQuery ajaxForm and CKEditor not saving as it shouldjQuery ajaxForm 和 CKEditor 没有按应有的方式保存
【发布时间】:2012-03-06 21:56:47
【问题描述】:

您好,很抱歉,这是一个非常大的系统的一部分,如果我遗漏了一些东西,我不会全部说明,请向我索取,

我正在使用 jQuerys ajaxForm http://jquery.malsup.com/form/ 和CKEditorhttp://ckeditor.com

根据 CKeditor 上的文档,jQuery 适配器与“代码与编辑器实例的交互”部分底部的 ajaxForm http://ckeditor.com/blog/CKEditor_for_jQuery 一起使用,

现在我的所有内容都使用 AJAX 加载到页面中,并且一个名为 addonLoader 的函数被传递给它的数据触发,这是该函数中处理 CKEditor 的部分

    // check there are not any instance's of CKEditor running
    $(".addonContent form textarea.editor").each(function(index, element) {
        $(this).ckeditor(function(){  this.destroy(); });
    });

    // add the content to the output area
    $(".addonContent").html(data);  

    // setup Ajax form values
    AJAXFormOptions = {
        success:       addonLoader
    };

    // activate ajaxForm on any forms from the data shown
    $(".addonContent form").ajaxForm(AJAXFormOptions);
// enable the content editor
$(".addonContent form textarea.editor").ckeditor({width:"800px"});

当我的表单通过图片链接提交时触发此代码

function submitForm(formID){
    (function($){
        $(".addonContent form textarea.editor").each(function(index, element) {
            $(this).ckeditor(function(e){
                this.updateElement();
            });
        });
        $(formID).submit(function(){    
            // prevent the browser redirect 
            return false;
        });
        $(formID).submit();
    })(jQuery)
}

我检查了formID是否正确,但由于某种原因它仍然没有用放置在CKEditor中的内容更新textarea 有没有人遇到这个问题并且知道如何解决它?

【问题讨论】:

  • 这里多了一个逗号:success: addonLoader, 会破坏 IE
  • 感谢并修复但不会停止错误

标签: jquery ckeditor ajaxform


【解决方案1】:

您用来调用updateElement()this 是一个DOM 节点,而不是ckeditor 对象。

在您提供的适配器链接上,它显示了如何从文档中访问编辑器实例,如下所示:

 var editor = $('.jquery_ckeditor').ckeditorGet();

尝试将this.updateElement() 更改为:

 $(this).ckeditorGet().updateElement()

现在您应该在编辑器实例上调用更新

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-11
    相关资源
    最近更新 更多