javascript - ExtJS multiple listeners - Stack Overflow

I have a property grid that I want to add multiple "afterrender" listeners to. Is it possible

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.

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.

Share Improve this question asked Jul 2, 2015 at 8:30 Ben IrvingBen Irving 4931 gold badge6 silver badges21 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 8

Another way to call multiple functions with the same event is by using on:

...
initComponent: function () {
  var me = this;
  me.on('afterrender', me.functionA);
  me.on('afterrender', me.functionB);
  ...
  me.on('afterrender', me.functionN);
  me.callParent(arguments);
}

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();
        }
    }
});

yes it is possible. you can add it with "addListener" function.

You can do it by calling several functions in a callback function with its all arguments, like this:

afterrender: function() {
    Foo.apply(this, arguments);
    Bar.apply(this, arguments);
}

Now you can define functions Foo and Bar and it would be called with all afterrender callback function arguments.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743604451a4477613.html

相关推荐

  • javascript - ExtJS multiple listeners - Stack Overflow

    I have a property grid that I want to add multiple "afterrender" listeners to. Is it possible

    5天前
    70

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信