在 CKEditor 中使用 jQuery 选择输入元素
好吧,这让我发疯——我只是不明白为什么这这么困难。
我创建了一个 CKEditor 并将我自己的选项卡添加到图像对话框中。在此新选项卡中,用户可以从列表中选择图像 URL。
我想根据此信息设置图像 url 框(第一个选项卡上的标准输入框)。通常我可以通过 ID 或类来选择它,但 CKEditor 每次都会为每个输入提供不同的 ID。
有没有一种简单的方法可以选择对话中的其他元素,因为在这里和在线阅读这些内容似乎没有意义。
(为什么不能所有东西都有一个像“#image_input_1_1”这样的漂亮ID,这意味着图像选项卡,输入1,CKEditor实例1,这会容易得多......)
Okay, this one is driving me crazy - I just don't understand why this is so difficult.
I have created an CKEditor and added my own tab to the images dialogue. In this new tab users can select an image URL from a list.
I would like to set the image url box (a standard input box on the first tab) from this information. Normally I could select this through an ID or class but CKEditor gives every input a different ID each time.
Is there an easy way to select other elements in the dialogue, as reading the stuff here and online just doesn't seem to make sense.
(why couldn't everything just had a nice id like "#image_input_1_1", which would mean the image tab, input 1, CKEditor instance 1, it would be so much easier...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最后,我这样做了:
我希望这对将来的人有帮助。
In the end, I did this:
I hope this will help someone in the future.
您可以进行一些 DOM 遍历:转到最近的公共父级,然后从那里下降到图像选项卡,然后按类/标签名称选择输入。
更新:
好吧,这是您的遍历,就像围绕 CKeditor 极其复杂的 DOM 树进行一次小旅行:
其中
this
是自定义选项卡中的某个元素。You can do some DOM traversing: Go to the closest common parent and from there decend into the images tab and select the input by classes/tag names.
Update:
Alright, here is your traversing, like a little trip around the CKeditor insanely complex DOM tree:
Where
this
is some element inside your custom tab.如果您正在谈论默认的图像对话框,那么您可以这样做:
如果您需要使用其他输入,请使用 devTools 插件: http://docs.cksource.com/CKEditor_3.x/Howto/Field_Names
If you're talking about the default Image dialog, then you can do it this way:
If you need to use other inputs use the devTools plugin: http://docs.cksource.com/CKEditor_3.x/Howto/Field_Names