热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

在创建YUIRTE工具栏后修改它-ModifyingaYUIRTEtoolbarafterit'sbeencreated

IaminasituationwhereIdonotcontrolthecreationofoneormanyYUIRichTextEditors;itis

I am in a situation where I do not control the creation of one or many YUI Rich Text Editors; it is done in someone else's library.

我处于一种我无法控制一个或多个YUI富文本编辑器的创建的情况;它是在别人的图书馆里完成的。

For the purposes of this discussion:

出于本讨论的目的:

  • patching code-- monkey or otherwise-- is not an option.
  • 修补代码 - 猴子或其他 - 不是一种选择。

  • removing (editor.destroy()) the editor that's already there and adding my own is also not an option. The code that creates the editor does Other Things to it and refers to the reference etc-- I need to modify the current editor.
  • 删除(editor.destroy())已经存在的编辑器并添加我自己的编辑器也不是一个选项。创建编辑器的代码执行其他事情并引用引用等 - 我需要修改当前编辑器。

By creation I mean:

通过创作我的意思是:

var myEditor = new YAHOO.widget.Editor(control, {
  // toolbar config would go here if I controled this code
});

myEditor.render();

The problem is that I would like these editors to have a different toolbar configuration to what they have. To be precise, I would like to remove a bunch of buttons (The default is a bit bloated).

问题是我希望这些编辑器具有不同的工具栏配置。确切地说,我想删除一堆按钮(默认有点臃肿)。

I managed to get the editor with the EditorInfo tool, but I couldn't really do anything with it. There is apparently a variable on the Editor that allows you to get the Toolbar instance but when I tried it all I got was null.

我设法使用EditorInfo工具获取编辑器,但我无法用它做任何事情。编辑器上显然有一个变量可以让你获得工具栏实例,但是当我尝试它时,我得到的只是null。

So, is there a way to modify a YUI Rich Text Editor after render() has been called to remove toolbar buttons?

那么,有没有办法在调用render()后删除工具栏按钮来修改YUI富文本编辑器?

1 个解决方案

#1


Since I can't see the code, it's a little hard to give an answer. But once you have access to the Editor instance, the toolbar property should give you full access to the addButton/detroyButton methods.

由于我看不到代码,所以给出答案有点难。但是一旦您可以访问Editor实例,工具栏属性就可以让您完全访问addButton / detroyButton方法。

var editor = YAHOO.widget.EditorInfo._instances['editor_id'];
editor.toolbar.destroyButton('bold'); //This should destroy the bold button

That code should work. If editor.toolbar is null, then you may be accessing it before the toolbar is created. You can try this:

该代码应该有效。如果editor.toolbar为null,则可能在创建工具栏之前访问它。你可以试试这个:

editor.on('toolbarLoaded', function() {
  this.toolbar.destroyButton('bold');
});

Again, it's a little tough to debug without seeing the code or having access (Firebug) to the page.

同样,在没有看到代码或访问(Firebug)页面的情况下调试有点困难。

I don't use this site, so you may want to ask the question on the official YUI mailing list so others can learn too ;)

我不使用这个网站,所以你可能想在官方YUI邮件列表上提问,以便其他人也可以学习;)


推荐阅读
author-avatar
Jing
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有