如何使用JQuery获取CKEditor的内容?

问题描述:

我正在使用CKEditor.我正在使用页面方法使用ajax保存表单值.

I'm using CKEditor. I am saving the form values with ajax using page methods.

但是CKEditor值的内容无法保存到表中.

But the content of CKEditor value cannot be saving into the table.

我不回发页面.

我该怎么办?

首先,您应该在页面中包括ckeditor和jquery连接器脚本

First of all you should include ckeditor and jquery connector script in your page,

然后创建一个文本区域

<textarea name="content" class="editor" id="ms_editor"></textarea>

将ckeditor附加到文本区域,在我的项目中,我使用如下代码:

attach ckeditor to the text area, in my project I use something like this:

$('textarea.editor').ckeditor(function() {
        }, { toolbar : [
            ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
            ['Undo','Redo'],
            ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
            ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
            ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
            ['Link','Unlink','Anchor', 'Image', 'Smiley'],
            ['Table','HorizontalRule','SpecialChar'],
            ['Styles','BGColor']
        ], toolbarCanCollapse:false, height: '300px', scayt_sLang: 'pt_PT', uiColor : '#EBEBEB' } );

在提交时使用以下内容获取内容:

on submit get the content using:

var content = $( 'textarea.editor' ).val();

就是这样! :)