CKEditor 如何获取 UIElement
我需要在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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 theUIElement
instance of any CKEditor object you're after.您可以在对话框初始化期间在
setup
回调中缓存您需要的内容吗?您可以向
setup
函数传递一个对象,它们可以将需要的内容放在那里。因此,您可以将一个对象传递到您的设置中:然后在您的
setup
中:那么至少您可以访问所有真实的 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:And then in your
setup
:Then at least you'd have access to all the real DOM id attributes and you could
getElementById()
as needed.感谢您的建议 mu 太短,
我发现我可以使用此方法访问其他选择菜单:
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.getValue will have the same id of the CKEditor UI element I'm after