Question

Hello i'm sorry this is part of a very large system and i'm not going to put it all if i'm missing some thing please ask me for it,

I'm using jQuerys ajaxForm http://jquery.malsup.com/form/ and CKEditor http://ckeditor.com

Accourding to documentation on CKeditor the jQuery adapter works with ajaxForm http://ckeditor.com/blog/CKEditor_for_jQuery at the bottom of the "Code interaction with editor instances" section,

now all my content is loaded into the page with AJAX and a function called addonLoader is fired with the data passed into it this is the section of that function that handles the 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"});

When my form is submited by a image link to fire this code

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)
}

I have checked that the formID is correct, but for some reason it still does not update the textarea with the content that is placed inside the CKEditor has any one had this problem and knows how to fix it?

Was it helpful?

Solution

The this you are using to call updateElement() is a DOM node not the ckeditor object.

On the adapter link you provided it shows how to get access to the editor instance as follows from docs:

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

Try changing this.updateElement() to :

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

Now you should be calling the update on editor instance

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top