I\'m using CKEditor. I am saving the form values with ajax using page methods.
But the content of CKEditor value cannot be saving into the table.
I dont post
To get data of ckeditor, you need to get ckeditor instance
HTML code:
<textarea class="form-control" id="reply_mail_msg" name="message" rows="3" data-form-field="Message" placeholder="" autofocus="" style="display: none;"></textarea>
Javascript:
var ck_ed = CKEDITOR.instances.reply_mail_msg.getData();
If you don't hold a reference to the editor, as in Aeon's answer, you can also use the form:
var value = CKEDITOR.instances['my-editor'].getData();
Now that jQuery adapter exists, this answer needs to be updated:
Say you initiated the editor with $('.ckeditor').ckeditor(opt)
then you get the value with $('.ckeditor').val()
you can retreive data like this :
<script>
var data = CKEDITOR.instances.editor1.getData();
// Your code to save "data", usually through Ajax.
</script>
reference : http://docs.ckeditor.com/#!/guide/dev_savedata
Easy way to get the text inside of the editor or the length of it :)
var editorText = CKEDITOR.instances['<%= your_editor.ClientID %>'].getData();
alert(editorText);
var editorTextLength = CKEDITOR.instances['<%= your_editor.ClientID %>'].getData().length;
alert(editorTextLength);
First of all you should include ckeditor and jquery connector script in your page,
then create a textarea
<textarea name="content" class="editor" id="ms_editor"></textarea>
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();
That's it! :)