开发者

Returning data from ckeditor with mulitple instances

开发者 https://www.devze.com 2023-01-23 04:44 出处:网络
I\'ve got several ckeditor instances on the same page which each is submitting a different form however the data is not being submitted.I\'ve tried 开发者_StackOverflow社区getting the ckeditor instanc

I've got several ckeditor instances on the same page which each is submitting a different form however the data is not being submitted. I've tried 开发者_StackOverflow社区getting the ckeditor instance using other methods but I am unable to get the correct instance, it's always giving me the first one so I'm unable to grab the data. The documentation says that with jquery ckeditor should automatically return the correct data, however it is not. What am I missing here?

$('.newmail').submit(function(event) { 
            var CKEDITOR   = window.parent.CKEDITOR;   
    for ( var i in CKEDITOR.instances ){
       var currentInstance = i;
       break;
    }

    var oEditor   = CKEDITOR.instances[currentInstance].getData();

            alert(oEditor);

    $(this).ajaxSubmit({
        dataType: 'json',
        success: $(this).processJson
    }); 

    return false; 
});


Is your form working properly even without ckeditor? It looks like the html code is not well organized; make sure your tags are closed in the right way


Seeing as you use jQuery, perhaps it would be better if you implemented ckEditor with the help of its jquery adapter? You can instantiate it by doing the following:

$("#id_of_textarea").ckeditor();

Then you can do the following for each editor instance before you submit your form:

$("textarea#id_of_textarea").val($("#id_of_textarea.editor").val());

That way, the value that has been entered into the editor will be set as the textarea value, and the submit will catch it.

0

精彩评论

暂无评论...
验证码 换一张
取 消