ExtJS多个听众 [英] ExtJS multiple listeners

查看:88
本文介绍了ExtJS多个听众的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个属性网格,我想添加多个afterrender监听器。可以添加同一类型的多个监听器,还是在一个监听器内启动多个功能?



我试过:

  afterrender:function(){...},
function(){...}
pre>

但它不会触发这两个功能。

解决方案

只需在函数回调函数中进行多个函数调用。下面显示了一个完整的例子...



工作小提琴

  Ext.create('Ext.grid.property.Grid',{
标题:'属性网格',
width:300,
renderTo:Ext.getBody(),

functionOne:function(){
alert(functionOne called );
},

functionTwo:function(){
alert(functionTwo called);
},

listeners :$ {

}

$ }
});


I have a property grid that I want to add multiple "afterrender" listeners to. Is it possible to add multiple listeners of the same type, or fire multiple functions within one listener?

I've tried:

afterrender: function(){...},
function(){...}

but it does not fire both of the functions.

解决方案

Just make multiple function calls within the function callback. Below shows a full example of this...

Working Fiddle

Ext.create('Ext.grid.property.Grid', {
    title: 'Properties Grid',
    width: 300,
    renderTo: Ext.getBody(),

    functionOne: function() {
        alert("functionOne called");
    },

    functionTwo: function() {
        alert("functionTwo called");
    },

    listeners: {
        afterrender: function() {
            var me = this;
            me.functionOne();
            me.functionTwo();
        }
    }
});

这篇关于ExtJS多个听众的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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