在jquery中添加多个CKEditor实例 [英] Adding multiple CKEditor instances in jquery

查看:291
本文介绍了在jquery中添加多个CKEditor实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试各种所见即所得JavaScript文字区域。如果我试图把CKEditor放在每个< textarea> 在我的屏幕上使用jquery,编辑器都显示正常,但他们不保存。我试过:

I'm experimenting with various WYSIWYG javascript text areas. If I try to put a CKEditor on every <textarea> on my screen with jquery, the editors all show up fine, but they don't save. I've tried:

$(function() {
$('.editors').ckeditor();
});

$(function() {
$('.editors').each(function(index, element){
    $(element).ckeditor();
});
});

在这两种情况下,每个文本区域都有一个CKEditor,但它不保存。如果我手动添加所有编辑器

In both instances, every text area has a CKEditor on it, but it doesn't save. If I manually add all the editors with

$(function() {
CKEDITOR.replace('contactText');
CKEDITOR.replace('edit_footer_text');
CKEDITOR.replace('termsText');
});

$(function() {
$('#contactText').ckeditor();
$('#edit_footer_text').ckeditor();
$('#termsText').ckeditor();
});

这三个字段都有编辑器,并保存。

All three fields have editors, and they save.

我试图在这个项目的标准模板中添加一些代码,如果我们想要编辑器的文本区域,他们只需要添加类的编辑器,这就是为什么我看用于jQuery解决方案。这对tinymce有效:

I'm trying to put some code in the standard template for this project so that if we want editors on the text areas, they just have to add the class 'editors' to them, so that's why I'm looking for jQuery solutions. This did work with tinymce:

$(function() {
     $('.editors').tinymce({
           script_url : '/common/tiny_mce/tiny_mce.js',
               // General options
               mode : "textareas",
              theme : "advanced",
         })
});


推荐答案

实际上,CKEditor的jQuery Adapter不更新默认情况下,您需要用当前的id替换编辑器。

Actually, jQuery Adapter for CKEditor, does not update the form element by default, you need to replace the editor with the current id.

$(function() {
$('.editors').each(function(){
    CKEDITOR.replace( $(this).attr('id') );
});
});

参考

这篇关于在jquery中添加多个CKEditor实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆