1

你好我很抱歉这是一个非常大的系统的一部分,如果我遗漏了一些东西,我不会把它全部放出来,请向我索取,

我正在使用 jQuerys ajaxForm http://jquery.malsup.com/form/ 和 CKEditor http://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 有没有人有这个问题并且知道如何解决它?

4

1 回答 1

1

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

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

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

尝试更改this.updateElement()为:

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

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

于 2012-03-07T01:22:05.200 回答