$(document).on('change', "input[name='child']", function() {
CKEDITOR.config.contentsCss = 'lib/bootstrap/css/bootstrap.css', 'lib/css/myStyle.css';
CKEDITOR.config.extraPlugins = 'font';
var pjID = {};
var pjDesc = [];
$("input[name='child']:checked").each(function() {
pjDesc.push($(this).val());
});
if ($(this).prop("checked") == true) {
pjID.projectsk = $(this).val();
$.ajax({
url: 'sample.php',
type: 'POST',
data: pjID,
success: function(result) {
var response = JSON.parse(result);
var content = CKEDITOR.instances.projectEditor.getData();
CKEDITOR.instances.projectEditor.setData(content + response.data[0].project_desc);
},
error: function(error) {
console.log(error);
}
});
}
else if ($(this).prop("checked") == false) {
var content = "";
var contentVal = "";
$.each(pjDesc, function(key, val) {
pjID.projectsk = val;
$.ajax({
url: 'sample.php',
type: 'POST',
data: pjID,
success: function(result) {
var response = JSON.parse(result);
console.log(response);
content = response.data[0].project_desc;
contentVal = contentVal+"<br>"+content;
console.log(contentVal);
},
error: function(error) {
console.log(error);
}
});
console.log('contentVal',contentVal);
CKEDITOR.instances.projectEditor.setData(contentVal);
});
}
CKEDITOR.replace('projectEditor');
});
The above code completely works except for the this line CKEDITOR.instances.projectEditor.setData(contentVal);. I get the exact output in console. But I am not able to set the value in ckeditor. I have tried using insertHtml,insertText and also foocallback(). Kindly help me out