CKEDITOR.replace('editor1','editor2',{

时间:2014-02-11 12:36:12

标签: javascript ckeditor

http://gw.ablueman.co.uk/tabbednotepad.php

我有3个ckeditor textareas,所有三个都是相同的,但与主要的或类别相当不同。

如果我放3次替换,它可以正常工作。但是,如果我尝试使用CKEDITOR.replace('editor1','editor2','editor3'{{/ p>

它起作用,取代它们,但忽略了{几乎就像类。

之后的任何东西

我只是格式化CKEDITOR.replace('editor1','editor2',{});错误的,我需要所有三个使用相同的替换。

下面是代码:

<form name="title" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>">
<textarea class="ckeditor" id="editor3" name="editor3" rows="200"><?php echo $editor3;?></textarea>
<input id="tabtitle1" name="tabtitle1" size="30" placeholder="Tab Title.." />
<input type="submit" value="Submit" >
</form>

<script type="text/javascript">   
    CKEDITOR.replace( 'editor1', {
    height: '600px',
    enterMode: CKEDITOR.ENTER_BR, 
    toolbar:    
[   { name: 'document', groups: [ 'document', 'doctools' ], items: [ 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates' ] },
    { name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
    { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl' ] },        '/',
    { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
    { name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] }, { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] },
    { name: 'insert', items: [ 'Image', 'Table', 'HorizontalRule', 'SpecialChar', 'PageBreak', 'Iframe', 'Syntaxhighlight' ] }, '/',
    { name: 'styles', items: [ 'Format', 'Font', 'FontSize' ] },
    { name: 'colors', items: [ 'TextColor', 'BGColor' ] },
    { name: 'others', groups: [ 'mode' ], items: [ 'Source', 'searchCode', 'autoFormat', 'CommentSelectedRange', 'UncommentSelectedRange', 'AutoComplete', '-', 'ShowBlocks' ] },
    { name: 'tools', items: [ 'Maximize' ] },
]});    
</script>

[编辑]仅供参考,我尝试了CKEDITOR.replace(['editor1','editor2'], 这也没有用。

3 个答案:

答案 0 :(得分:4)

Ckeditor 4允许您使用基于classname的编辑器替换多个textareas:

CKEDITOR.replaceAll('className');

docs

答案 1 :(得分:3)

您可以使用textarea id数组,使用jquery和foreach调用CKEDITOR.replace。例如:

 var areas = Array('editor1', 'editor2', 'editor3');
    $.each(areas, function (i, area) {
     CKEDITOR.replace(area, {
      customConfig: '/Scripts/ckeditor/config.mini.js'
     });
    });

答案 2 :(得分:1)

您无法同时使用多个ID调用CKEDITOR.replace。

Its definition表示第一个参数是ID或元素,第二个参数是配置选项。

相关问题