【问题标题】:Adding multiple CKEditor instances in jquery在 jquery 中添加多个 CKEditor 实例
【发布时间】:2011-10-05 12:25:52
【问题描述】:

我正在试验各种 WYSIWYG javascript 文本区域。如果我尝试使用 jquery 在我的屏幕上的每个<textarea> 上放置一个 CKEditor,编辑器都显示得很好,但他们不保存。我试过了:

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

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

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

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

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

所有三个字段都有编辑器,并且它们保存。

我正在尝试在该项目的标准模板中添加一些代码,这样如果我们想要文本区域的编辑器,他们只需向它们添加类“编辑器”,这就是我要寻找的原因jQuery 解决方案。这确实适用于tinymce:

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

【问题讨论】:

    标签: jquery ckeditor


    【解决方案1】:

    其实CKEditor的jQuery Adapter,默认不更新表单元素,需要将编辑器替换为当前id。

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

    Reference

    【讨论】:

    • 奇怪的是,它显示编辑器。我认为这是一个错误。
    • @PaulTomblin 解释原因??
    • @GauravAggarwal 因为用$('.editors').each(function(index, element){ $(element).ckeditor(); }); 附加CKeditor 就足够了,因为.ckeditor 可以访问项目的ID。
    • element.ckeditor(options) 对我有用。我不必使用替换。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多