CKEditor Not updating Textarea value on form submit
CKeditor is a very popular and free rich-text editor and it's easy to use, But sometimes we face an issue with it, like when we submit a form through ajax or PHP , it not submit the updated content and keep sending old content on form submit.
So here is the solution to this issue
Before submitting the form , add below code that will check all CKeditor instances and loop it and then will update its content, so after this code, if you have multiple textarea in your page, then still this code will work.
for ( instance in CKEDITOR.instances )
CKEDITOR.instances[instance].updateElement();
So here is the solution to this issue
Before submitting the form , add below code that will check all CKeditor instances and loop it and then will update its content, so after this code, if you have multiple textarea in your page, then still this code will work.
for ( instance in CKEDITOR.instances )
CKEDITOR.instances[instance].updateElement();
Example:
In this example , I am submitting a form through ajax and I am adding code in it so textarea will have updated content.
CODE:
$("#btnSaveDetails").on("click", function() {
var el = $(this);
for ( instance in CKEDITOR.instances )
CKEDITOR.instances[instance].updateElement();
var getForm = $("#idFormDetails");
$.ajax({
url: getForm.attr('action'),
type: "post",
data: getForm.serialize(),
dataType: 'json',
success: function(response) {
},
error: function() {
}
})
})
Important Links
CKEditor issue with updating Textarea value
CKEditor content into textarea on change event - beginner ...
CKEditor reupdate code of textarea
How to update textarea content in CKEditor
})
})
Important Links
CKEditor issue with updating Textarea value
CKEditor content into textarea on change event - beginner ...
CKEditor reupdate code of textarea
How to update textarea content in CKEditor
Comments
Post a Comment