2011-01-28 12 views
10
codice

mio CKEditor èOttieni contenuti CKEditor? - jQuery

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

voglio prendere il contenuto della casella di modifica e inviarlo via JSON dal mio script jQuery. Non riesco a trovare come farlo.

risposta

36

questo è spiegato nella integration Guide

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

È possibile utilizzare anche l'integrazione di jQuery come spiegato nella CKEditor blog e jQuery integration docs

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