Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the content of CKEditor using JQuery?

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 postback the page.

What can I do for that?

like image 520
pegasus Avatar asked Sep 26 '10 18:09

pegasus


People also ask

How do I get CKEditor content?

If you need to get the actual data from CKEditor 4 at any moment using JavaScript, use the editor. getData() method as described above.

How can I get multiple CKEditor values in jQuery?

each(function(index, element){ $(element). ckeditor(); }); should be enough since . ckeditor has access to the item's id. element.

Does CKEditor use jQuery?

Thanks to these changes CKEditor 4 automatically works with the official jQuery Form Plugin for Ajax-based forms. It does not require any action from the developer's side to support it.

How do I view data in CKEditor?

You can display data in ckeditor by passing the variable value which you get from the database.


1 Answers

use the CKEditor.editor.getData() call on the instance. That is to say:

HTML

<textarea id="my-editor"> <input id="send" type="button" value="Send"> 

JS for CKEditor 4.0.x

$('#send').click(function() {     var value = CKEDITOR.instances['DOM-ID-HERE'].getData()     // send your ajax request with value     // profit! }); 

JS for CKEditor 3.6.x

var editor = CKEDITOR.editor.replace('my-editor');  $('#send').click(function() {     var value = editor.getData();     // send your ajax request with value     // profit! }); 
like image 162
Aeon Avatar answered Oct 14 '22 16:10

Aeon