Events ExtJS:为事件处理程序传递参数
我像这样连接事件处理程序:Events ExtJS:为事件处理程序传递参数,events,extjs,Events,Extjs,我像这样连接事件处理程序: Ext.getCmp('MyButton').on('click', this.onClick, null, {info: "foo"}); function onClick(event, target, options) { alert(options); } 处理程序如下所示: Ext.getCmp('MyButton').on('click', this.onClick, null, {info: "foo"}); function onClick(e
Ext.getCmp('MyButton').on('click', this.onClick, null, {info: "foo"});
function onClick(event, target, options) {
alert(options);
}
处理程序如下所示:
Ext.getCmp('MyButton').on('click', this.onClick, null, {info: "foo"});
function onClick(event, target, options) {
alert(options);
}
我收到了回拨,但
选项
作为未定义
发出。怎么了?在我看来,我正在做我建议的事情 你在做文档所说的,但你对文档的解释是错误的。可以作为第四个参数传递的选项文本配置侦听器(设置如延迟、范围等)。不能使用它向侦听器函数传递额外参数。这就是createDelegate的用武之地
var a = new Ext.Button({ text: 'Click!', renderTo: Ext.getBody() });
a.on('click', function(){
alert('click after 2 seconds!');
console.log(arguments); // will log the strings 'Hello' and 'World'
}.createDelegate(a, ['Hello', 'World']), null, { delay: 2000 });
因此,当文档说“您基本上只是向options对象添加自定义变量”,并给出设置“someProperty”然后在回调中读取它的示例时。。。那只是虚构的?(我承认可能是!)我只是在上查看了addListener文档,但找不到任何您所指内容的引用。你有链接吗?这是问题中的链接。当我更仔细地观察它时,它指的是Ext的一个旧版本,所以谜团被解开了。