Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load ckeditor in ajax content

I'm using CKEditor to change my textareas into a wysiwyg. It all works fine, except when i load content through an Ajax call. Then my CKEditor doesn't load.

I've searched for a solution, but couldn't find any that worked for me.

My Ajax call basically looks like this:

$.ajax({
    type: "POST",
    url: url,
      success: function(data) {
            $('#content').html(data);
            $('.ckeditor').ckeditor();
      }
});

As you can see i tried to use the function ckeditor() to programmatically load the CKEditor. But this gives me the following error:

FireFox says:

$(".ckeditor").ckeditor is not a function

And IE says:

Object doesn't support property or method 'ckeditor'

Is there any other way to load the CKEditor by class name when the content is loaded through an Ajax call??

like image 960
w00 Avatar asked Jul 09 '12 19:07

w00


2 Answers

First you have to load the jquery adapter '/path/to/ckeditor/adapters/jquery.js'

Than $('.ckeditor').ckeditor(); will work.

like image 177
Guest Avatar answered Dec 03 '22 07:12

Guest


you can use command:

CKEDITOR.replace( 'editor1' );

but with one difference - editor1 is the id of the textarea and not the class.

like image 28
StanleyD Avatar answered Dec 03 '22 07:12

StanleyD