Search code examples
javascripthtmlckeditorckeditor4.x

CKEditor - not submit data in in post


I have html code in my form:

<textarea name="page_desc" class="form-control" id="page_desc" placeholder="Page Description" rows="5"></textarea>

Following is my javascript:

    $(document).ready(function() {
        CKEDITOR.replace('page_desc');
    });

It loads the ckeditor in form, but when I submit the form it doesn't pass the data in page_desc field. I checked in post data. page_desc field is blank. Then I tried this:

    CKEDITOR.instances.page_desc.on('blur', function(e) { 
        console.log(e); //see screenshot below what it returns
        console.log(document.getElementById('page_desc').value);//it is blank
    });

In console I get this: enter image description here

data is undefined here.


Solution

  • CKEditor doesn't provide data like this. You have to use the code as follows:

    CKEDITOR.instances.page_desc.getData();
    

    And have to submit the data by using custom ajax.