CKEditor 如何获取 UIElement

发布于 2024-12-03 06:00:52 字数 639 浏览 1 评论 0原文

我需要在 CKEditor 对话框中有两个选择菜单,第二个选择菜单根据第一个菜单的选定选项更改其选项。你会想很简单!但在 CKEditor 中似乎很难获得 CKEditor 对象的 DOM 等价物。我可以访问 CKEditor 对象,但不能访问其 DOM 等效项。

CKEditor select (UIElement) 对象的实例有一些有用的 DOM 交互,即 getElement() 但我只能在事件方法中使用特殊的 this 关键字访问该对象CKEditor 选择“类”定义。

如何访问 CKEditor UIElement 对象的实例(在本例中为 select)?我只有 CKEditor 对象的 id,由于某些令人沮丧的原因,CKEditor 决定将随机 id 应用于其 DOM 对象等效项。

我尝试访问的实例对象记录在此处:(但没有提及如何获取此实例!) http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR .ui.dialog.select.html

I need to have two select menus in a CKEditor dialog, with the second select menu changing its options according to the selected option of the first menu. Simple enough you would think! But in CKEditor it seems really difficult to obtain the DOM equivalent of the CKEditor object. I can access the CKEditor Object but not its DOM equivalent(s).

The instance of the CKEditor select (UIElement) object has some useful DOM interactions i.e. getElement() but I can only access this object with the special this keyword within an event method within a CKEditor select "class" definition.

How can I access the instance of the CKEditor UIElement object (in this case the select)? I only have the id of the CKEditor object, CKEditor for some frustrating reason decides to apply random ids to its DOM object equivalents.

The instance object I am trying to access is documented here: (No mention of how to obtain this instance though!)
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.ui.dialog.select.html

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

事实上,CKEDITOR.dialog.getCurrent() 方法将允许您从任何函数访问 Dialog 实例,并且从那里您可以访问任何 CKEditor 对象的 UIElement 实例你在追赶。

In fact the CKEDITOR.dialog.getCurrent() method will allow you to access the Dialog instance from any function, and from there you can access the UIElement instance of any CKEditor object you're after.

沫雨熙 2024-12-10 06:00:52

您可以在对话框初始化期间在 setup 回调中缓存您需要的内容吗?

您可以向 setup 函数传递一个对象,它们可以将需要的内容放在那里。因此,您可以将一个对象传递到您的设置中:

onShow: function() {
    //...
    this.cachedDomIds = { };
    this.setupContent(this.cachedDomIds);
    //...
}

然后在您的 setup 中:

setup: function(cache) {
    //...
    cache.some_dom_id = this.domId;
    //...
}

那么至少您可以访问所有真实的 DOM id 属性,并且您可以 getElementById()< /代码> 根据需要。

Can you cache what you need in the setup callbacks during your dialog's initialization?

You can pass the setup functions an object and they could put what they need in there. So you'd pass an object into your setup stuff:

onShow: function() {
    //...
    this.cachedDomIds = { };
    this.setupContent(this.cachedDomIds);
    //...
}

And then in your setup:

setup: function(cache) {
    //...
    cache.some_dom_id = this.domId;
    //...
}

Then at least you'd have access to all the real DOM id attributes and you could getElementById() as needed.

述情 2024-12-10 06:00:52

感谢您的建议 mu 太短,

我发现我可以使用此方法访问其他选择菜单:

this.getDialog().getContentElement([insert_dialog_name_here], this.getValue()).getElement()

this.getValue 将具有与我之后的 CKEditor UI 元素相同的 id

Thanks for the suggestion mu is too short,

I found I could access the other select menus by using this method:

this.getDialog().getContentElement([insert_dialog_name_here], this.getValue()).getElement()

this.getValue will have the same id of the CKEditor UI element I'm after

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文