T K
T K

Reputation: 11

CKEditor returns [object Object]

I've turned on CKEditor to my textarea. Every time, when I try to proceed typed text in it, CKEditor returns [object Object] instead of any content.
What should I do and what could I missed? Please, help to noob

Used $('#area-answer').val(CKEDITOR.instances["area-answer"].getData()) construction

Upvotes: 0

Views: 529

Answers (3)

Sandeep Chavda
Sandeep Chavda

Reputation: 1

HTML

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

JS for CKEditor

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

Upvotes: 0

Aman Kumar
Aman Kumar

Reputation: 4557

Get value of CK-Editor

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

function submition() {
   var areaText = CKEDITOR.instances['area'].getData();
    alert(areaText);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="https://openconcept.ca/sites/all/libraries/ckeditor/ckeditor.js"></script>
 <link rel="stylesheet" href="https://raw.githubusercontent.com/kevee/quail/master/examples/common/style.css">
 
 
<form  method="post">
    <!-- same strings-->
    <textarea id="area" ></textarea>
    <input type="button" value="Save" onclick="submition();" />
</form>

Upvotes: 1

Rohit Kumar
Rohit Kumar

Reputation: 94

try to use html() instead of use val();

Upvotes: 0

Related Questions