Get CKEditor content? - jQuery

霸气de小男生 提交于 2019-12-03 12:23:55

问题


My CKEditor code is

window.onload = function()
{
    var editor = CKEDITOR.replace( \'big_info\' );
    CKEDITOR.config.height = \'330px\';
    CKEDITOR.config.toolbar_Full =
    [
        [\'Source\',\'-\',\'Templates\'],
        [\'Maximize\', \'ShowBlocks\'],
        [\'Cut\',\'Copy\',\'Paste\',\'PasteText\',\'PasteFromWord\',\'-\',\'SpellChecker\', \'Scayt\'],
        [\'Undo\',\'Redo\',\'-\',\'Find\',\'Replace\',\'-\',\'SelectAll\',\'RemoveFormat\'],
        [\'TextColor\',\'BGColor\'],

        [\'NumberedList\',\'BulletedList\',\'-\',\'Outdent\',\'Indent\',\'Blockquote\'],
        \'/\',
        [\'Bold\',\'Italic\',\'Underline\',\'Strike\',\'-\'],
        [\'Styles\',\'Format\',\'Font\',\'FontSize\'],
        [\'JustifyLeft\',\'JustifyCenter\',\'JustifyRight\',\'JustifyBlock\'],
        [\'Link\',\'Unlink\',\'Anchor\'],
        [\'Image\',\'Flash\',\'Table\',\'HorizontalRule\',\'PageBreak\']
    ];

    CKFinder.SetupCKEditor( editor, { BasePath : \'/javascript/ckfinder/\', RememberLastFolder : false } ) ;
};

I want to take the content of the edit box and send it via JSON from my jQuery script. I can't find how do to it.


回答1:


This is explained in the integration Guide

var editor_data = CKEDITOR.instances.big_info.getData();

You can use also the jQuery integration as explained in the CKEditor blog and jQuery integration docs

// Get the editor data.
var data = $( 'textarea.editor' ).val();
// Set the editor data.
$( 'textarea.editor' ).val( 'my new content' );


来源:https://stackoverflow.com/questions/4826036/get-ckeditor-content-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!