cm_w89 cm_w89 - 3 months ago 49
Javascript Question

ckeditor updateElement() Error

I have applied CKeditor to a text area on my form, but after Serializing the form, I checked it doesn't get the data from that field (description)
I found this in CKEditor's documentation:

CKEDITOR.instances.description.updateElement();
alert(document.getElementById( 'description' ).value);


I need to send that data somewhere through an API but it doesn't work without alert().
I wanted to grab this data into an variable like

var a = document.getElementById( 'description' ).value;


but it only works using the alert():

var a = alert(document.getElementById( 'description' ).value);


But I don't want that alert(). I just don't want to show its odd looking HTML code to the user.
Thank you for helping.

Answer

set the original textarea value to the ckeditor's value before serializing:

$("#OriginalTextAreaId").val(CKEDITOR.instances.description.getData());
Comments