检测 WordPress 编辑帖子页面的富文本编辑器 (tinyMCE) 中的更改事件
如何检测“编辑帖子”页面中的富文本编辑器发生更改?
我想要的是当用户在富文本编辑器(HTML 和可视化窗格)中键入内容时执行一个函数。
编辑:我在 HTML 窗格中完成了与tinyMCE 创建的隐藏文本区域中的 jQuery keyup 事件关联,但我仍然无法检测到 Visual 选项卡中的用户输入。
我正在使用 Wordpress 3.2.1,并且我知道他们正在使用tinyMCE 来实现富文本编辑器功能。
似乎 tinyMCE 使用 iframe
在富文本编辑器中构建 Visual 选项卡,所以我尝试了指出的示例 此处没有任何结果。
任何帮助表示赞赏。
How I can detect that there was a change in the rich text editor in the Edit Post page?
What I want is to execute a function when the user typed something in the rich text editor (HTML and Visual panes).
EDIT: I accomplished that in the HTML pane associating a jQuery keyup event in the hidden textarea that tinyMCE create, but still I've not been able to detect user input in the Visual tab.
I'm using Wordpress 3.2.1 and I know that they are using tinyMCE for the rich text editor functionality.
Seems that tinyMCE uses an iframe
to build the Visual tab in the rich text editor, so I tried the examples pointed here without any results.
Any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最后,我能够通过添加以下代码片段来解决这个问题:
感谢@HarkályGergő 的提示来解决这个问题:)
Finally I was able to solve this issue by adding this code snippet:
Thannks to @HarkályGergő for his prompting to solve this question :)
不知道如何将其添加到 WordPress,但从 TinyMCE 的角度来看 编辑器上的 isDirty() 方法应该有所帮助。
因此,您可以简单地使用
来检查当前活动的编辑器。 WordPress 可能会为您提供访问编辑器实例的替代方法。
Not sure how to add this to WordPress, but from a TinyMCE perspective the isDirty() method on the editor should help.
So you could simply use
to check the currently active editor. WordPress may give you alternative ways to access the editor instance.