code-8
code-8

Reputation: 58790

Can't access text from CKEditor

I have this text area

enter image description here

HTML

<textarea name="description" id="description"></textarea>

JS

CKEDITOR.replace( 'description' );
CKEDITOR.config.contentsCss = [CKEDITOR.getUrl('contents.css'), 
CKEDITOR.getUrl('/js/ckeditor/skins/moono-dark/styles.css')];

I did this

$('textarea[name="description"]').keyup(function() {
    console.log($('textarea[name="description"]').val());
});

I see nothing on my console.

Can someone show me how to debug this further?

Upvotes: 0

Views: 199

Answers (1)

Ciprian
Ciprian

Reputation: 56

To receive events and access the updated content of the textarea you must use the CKEDITOR object like this :

CKEDITOR.instances.description.on('change', function() { 
    console.log(CKEDITOR.instances.description.getData());
});

Upvotes: 1

Related Questions