ExtJS multiple listeners

I have a property grid into which I want to add several afterrender listeners. Is it possible to add several listeners of the same type or run several functions inside one listener?

I tried:

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

but it does not run both functions.

+4
source share
4 answers

Just make a few function calls in a function callback function. Below is a complete example of this ...

Working script

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

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

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

, . addListener.

0

, , :

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

Now you can define the functions Fooand Bar, and it will be called with all the arguments to the afterrenderfunction of the callback function.

0
source

All Articles