Skip to content Skip to sidebar Skip to footer

Ckeditor Not Loading On Element Generated Via Ajax Call?

I am using custom form and generating form elements with ajax call but textarea is not loaded with ckeditor. Here is my code: ajax code: jQuery.ajax({ type: 'POST', url

Solution 1:

Insert these lines:

ckeditor.replace('#fname'); // ADD THIS
$('#fname').ckeditor(); // ADD THIS

Your code should look like this:

jQuery.ajax({
type: "POST",
url: "reg_arz_ajax2.php",
data: "book="+book_arzyabi,
dataType : "html",
success: function(response){

    $('#resp').html(response);
    ckeditor.replace('#fname'); // ADD THIS
    $('#fname').ckeditor(); // ADD THIS
},
error:function (xhr, ajaxOptions, thrownError){
    //On error, we alert useralert(thrownError);
}
});

$( "#dialog-form" ).dialog( "open");

});

Solution 2:

for me having only this line worked:

ckeditor.replace('#fname');

and the following line needs to be REMOVED:

$('#fname').ckeditor(); // this does NOT work

also note, that ckeditor needs to be in caps, so:

CKEDITOR.replace('#fname');

Solution 3:

Add only CKEDITOR.replace('fname'); instead. The # is not necessary. Also, you do not have to add:

$('#fname').ckeditor();

Make sure it's uppercase throughout, eg CKEDITOR not ckeditor

Solution 4:

don't add ckeditor.replace('#fname'); you have to add $('#fname').ckeditor(); and in my project is works

Solution 5:

Edit this lines:

CKEDITOR.replace( 'fname' );

Your code should look like this:

jQuery.ajax({
type: "POST",
url: "reg_arz_ajax2.php",
data: "book="+book_arzyabi,
dataType : "html",
success: function(response){

    $('#resp').html(response);
    CKEDITOR.replace( 'fname' ); //this line should be changed like this
    $('#fname').ckeditor();
},
error:function (xhr, ajaxOptions, thrownError){
    //On error, we alert useralert(thrownError);
}
});

$( "#dialog-form" ).dialog( "open");

});

Post a Comment for "Ckeditor Not Loading On Element Generated Via Ajax Call?"