开发者

ckeditor using ajax

开发者 https://www.devze.com 2022-12-29 12:43 出处:网络
I am preparing a script. I am using AJAX(load()) with jQuery. I am getting a page which includes textarea with ckeditor by load() jQuery AJAX function.

I am preparing a script. I am using AJAX(load()) with jQuery.

I am getting a page which includes textarea with ckeditor by load() jQuery AJAX function.

Although I include ckeditor's.js file, load开发者_StackOverflowed page doesn't includes javascript file and shows a normal textarea without ckeditor.

How can I load file which includes textarea with ckeditor?


After creating the textarea with load(), you have to call CKEDITOR.replace() on any textareas which you have created, in order to initialize the editor... Are you doing this?

If you are loading multiple textareas, and you want all the textareas in the document to become CKEDITORs, then you do:

load();
CKEDITOR.replaceAll();


I am using ajax load like that:

$(".main").load("new_doc.php");

new_doc.php is:

<script type="text/javascript" src="files/ckeditor.js"></script>
<textarea class="ckeditor" cols="80" id="editor" name="editor" rows="10">asddsa</textarea>

I see only normal textarea.


OK friends I solve this solution:

I am getting new_doc.php (loaded page) with ckeditor by using jquery load(); fn.

So the codes see the basePath as new_doc.php's directory. I used this function:

CKEDITOR.basePath = "ckeditor/";

and I copied "skins" directory which is in the "ckeditor" directory to new_doc.php's directory.

And the solution is solved.

Thanks to everybody.


I can hack it using mouseMove then quickly remove .ckeditor class to avoid repetitions. Works for me so far

$("body").on("mousemove", function(){ 

    $('.ckeditor').each(function(index, element) {
       CKEDITOR.replaceAll();
      $(this).removeClass('ckeditor');
    });

});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号