问题描述
当点击一个按钮时,我使用 addClsOnOver
来更改按钮的按钮,它可以正常工作。第二次单击按钮, addClsOnOver
再次被调用,但使用不同的类,预计会发生多次,但不幸的是,由<$ c $创建的事件侦听器c> addClsOnOver 在第一次点击之后不会被覆盖。
我现在知道,如果我想改变它,我需要使用 removeListener()
然后 addClsOnOver
再次第一次,但不知道什么参数放在它中删除 addClsOnOver
监听器。
我确定它相当简单,但我没有猜测atm,不能在文档中找到任何可能建议自动生成的侦听器可能被调用的内容。
$ b $请帮助? :)
如果您没有在方法,指定事件的侦听器将被删除。
所以如果您不使用自己的监听器 mouseenter
和 mouseleave
可以用于删除由 addClsOnOver()
方法设置的侦听器的按钮元素:
//使用el.dom作为范围,因为在创建侦听器时使用el.hover方法
el.removeListener('mouseenter',null ,el.dom);
el.removeListener('mouseleave',null,el.dom);
以示例为例:
When a button is clicked, I use addClsOnOver
to change the over cls of the button and it works fine. The second time the button is clicked, addClsOnOver
is called again but with a different class and this is expected to happen multiple times but unfortunately, the event listeners created by addClsOnOver
are not over-written after the first click.I know now that I need to use removeListener()
and then addClsOnOver
if I want to change it again after the first time but dont know what parameters to put in it to remove the addClsOnOver
listener.I'm sure its fairly simple but I'm out of guesses atm and cant find anything in the docs that might suggest what the auto-generated listener might be called.
Help please? :)
If you do not set fn parameter in removeListener()
method, all listeners for specified event will be removed.
So if you do not use your own listeners for mouseenter
and mouseleave
on button element you can use for removing listeners seted by addClsOnOver()
method this code:
// use el.dom as scope because it is used el.hover method when listeners were created
el.removeListener('mouseenter', null, el.dom);
el.removeListener('mouseleave', null, el.dom);
Fiddle with example: https://fiddle.sencha.com/#fiddle/30d
这篇关于如何删除addClsOnOver监听器ExtJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!