简体   繁体   English

如何在同一网页上加载多个CKEditor工具栏

[英]How to load multiple CKEditor toolbars on the same web page

I have two divs on the same page using CKEditor. 我在使用CKEditor的同一页面上有两个div。 I can get a toolbar to load for the first div, but not the second. 我可以为第一个div加载一个工具栏,但不能为第二个加载。 I realize this is the case because I'm using an id for ckToolbar instead of a class. 我意识到是这种情况,因为我使用的是ckToolbar的ID而不是类。 However, if I use a class, the toolbar doesn't show up. 但是,如果使用类,则不会显示工具栏。

Div 1 1区

<div id="ckEditor">
    <div id="ckToolbar"></div>
    <div class="editor" data-bind="wysiwyg: txtBody, value:txtBody, valueUpdate:'keydown'"></div>
</div>

Div 2 2区

<div id="ckEditor">
    <div id="ckToolbar"></div>
    <div class="editor" data-bind="wysiwyg: txtHelpText, value:txtHelpText, valueUpdate:'keydown'"></div>
</div>

Config.js Config.js

config.extraPlugins = 'sharedspace';
config.sharedSpaces = { top: 'ckToolbar' };

I am also using Knockout JS. 我也在使用Knockout JS。 I created a custom binding and a div instead of a textarea because I couldn't use the CKEDITOR replace function with my binding. 我创建了一个自定义绑定和一个div而不是textarea,因为我无法在绑定中使用CKEDITOR replace函数。

You can't have two elements on the same page with same id's . 同一页上不能有两个具有相同id's元素。 How is JavaScript supposed to recognize which one you have in mind ? JavaScript应该如何识别您想到的是哪一个 You should either use classes or different id's and adjust you knockout code to handle that. 您应该使用classes或其他id's并调整基因剔除代码来处理。

Sorry for the general answer but there is simply no way around it. 很抱歉提供一般答案,但根本无法解决。 You can't have two elements with same id on a single page. 同一页上不能有两个具有相同id元素。

NOTE: CKEditor auto replaces elements with ckeditor class however if you are using knockout, I don't think this will me much of a use for you. 注意: CKEditor会自动ckeditor替换元素,但是,如果您使用的是淘汰赛,我认为这对您没有多大用处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM