首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >CKEDITOR.replace(‘编辑1’,‘编辑2’,{

CKEDITOR.replace(‘编辑1’,‘编辑2’,{
EN

Stack Overflow用户
提问于 2014-02-11 20:36:12
回答 3查看 24.9K关注 0票数 0

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

我有3个ckeditor textareas,这三个都是相同的,但与main或class有很大的不同。

如果我放3个替换,它工作得很好。但是,如果我尝试使用CKEDITOR.replace( 'editor1','editor2','editor3‘{

它可以替换它们,但会忽略{之后的任何内容,就像类一样。

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

代码如下:

代码语言:javascript
运行
复制
<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',这也不起作用。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-09-18 21:52:45

您可以使用一个文本区域id数组,并通过jquery和foreach调用一个CKEDITOR.replace。例如:

代码语言:javascript
运行
复制
 var areas = Array('editor1', 'editor2', 'editor3');
    $.each(areas, function (i, area) {
     CKEDITOR.replace(area, {
      customConfig: '/Scripts/ckeditor/config.mini.js'
     });
    });
票数 4
EN

Stack Overflow用户

发布于 2016-05-30 14:52:27

Ckeditor 4允许您使用基于类名的编辑器替换多个文本区域:

代码语言:javascript
运行
复制
CKEDITOR.replaceAll('className');

docs

票数 8
EN

Stack Overflow用户

发布于 2014-02-12 04:35:56

您不能同时使用多个ids调用CKEDITOR.replace。

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21702019

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档