[ACCEPTED]-How to clear ckeditor form after submitting with ajax?-ckeditor
Accepted answer
I use function setData
and all works fine:
function CKupdate(){
for ( instance in CKEDITOR.instances ){
CKEDITOR.instances[instance].updateElement();
CKEDITOR.instances[instance].setData('');
}
}
$(document).ready(function(){
CKEDITOR.replace( 'comment-textarea' );
var options = {
success: function (html) {
$('#comments').append(html);
},
clearForm: true
};
$('#formcomments').submit(function() {
CKupdate();
});
$('#formcomments').ajaxForm(options);
});
0
Try something like $("#comment-textarea").val("");
... it should go here.
$('#formcomments').submit(function() {
CKupdate();
$("#comment-textarea").val("");
});
#comment-textarea
is 3 the id of the textarea you want to clear 2 and .val(' ')
sets it's value to ' '
- notice the space 1 between the ';
Simply create instance and use setHtml
use this 1 inside submit
var Editor1 = FCKeditorAPI.GetInstance('comment-textarea'');
Editor1.SetHTML();
for ckeditor
setData
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#setData
I used this two method and worked for me
$(window).load(function(e) {
for ( instance in CKEDITOR.instances ){
CKEDITOR.instances[instance].updateElement();
}
CKEDITOR.instances[instance].setData('');
});
//OR
$.ajax({
type:'POST',
url:'response.php',
data: data,
cache:false,
success: function(e)
{
for ( instance in CKEDITOR.instances ){
CKEDITOR.instances[instance].updateElement();
}
CKEDITOR.instances[instance].setData('');
}
});
Hope 1 It helps
CKEDITOR.instances.msg.setData('');
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.