$(this).keyup()专注于tinyMCE时没有响应 [英] $(this).keyup() not responding when focused on tinyMCE

查看:134
本文介绍了$(this).keyup()专注于tinyMCE时没有响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在"keyup"事件发生时触发一个函数.当我在普通的textarea和输入字段上对其进行测试时,这可以很好地工作,但是,当我在tinyMCE编辑器上使用相同的代码时,什么也没发生.我怀疑这是因为tinyMCE在Java上运行,并且已经具有事件侦听器,但是我的Java知识距离解决这个问题还很远!

I'm trying to fire a function when the "keyup" event happens. This works fine when I'm testing it on normal textarea's and input fields, however, when I use the same code on the tinyMCE editor, nothing happens. I suspect it is because the tinyMCE is running on java, and already has event listeners in place, however my java knowledge is an age away from being anywhere near adiquate to deal with this problem!

这是我的代码,除了tinyMCE编辑器之外,它还可以处理页面上的所有输入:

This is my code that works an all inputs on the page, apart from the tinyMCE editor:

<script type="text/javascript">
$(document).ready(function() {

    $(this).keyup(function(){

        // get the contents of the editor...
        var content = tinyMCE.get('demo_textarea');
        content = escape(content.getContent());
        content = content.replace("+", "%2B");
        content = content.replace("/", "%2F");

        // copy the contents of the editor into #box_2
        $('#box_2').html(content);

    });

}
</script>

我实际上想要实现的是类似于堆栈溢出编辑器的功能,其中您的输入反映在另一个框中.

What I am actually trying to achieve is something similar to the stack overflow editor, where your input is reflected in another box.

感谢您的阅读,并在此先感谢您所提供的任何帮助.

Thanks for reading and thanks in advance for any help I may get.

关于, 汤姆

推荐答案

您可以在此处一个如何为tinyMCE编辑器设置事件处理程序的示例,您可以探索更多可能对您有用的示例.您只需要直接绑定编辑器的onkeyup事件即可.

You can see here an example how to setup events handler for tinyMCE editor, and you can explore more examples which probably will useful for you. All you need is directly bind onkeyup event of editor.

这篇关于$(this).keyup()专注于tinyMCE时没有响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆