Monday, June 29, 2015

ExtJS - Event Listening

  • ExtJS few events will be fired without user action like afterrender.
  • There are events will be fired based on the user action like click, double click, mouseover etc.

Following code demonstrates , how to fire the event when user clicked.

Ext.create('Ext.Button', {
    text: 'Click me to call listener',
    renderTo: Ext.getBody(),
    listeners: {
        click: function() {
            Ext.Msg.alert('Listener function called!');
        }
    }
});


Same way multiple listeners can be added for same component

listeners: {
        click: function() {
            Ext.Msg.alert('Listener function called!');
        },

        mouseover: function() {
            //mouseover functionality
        }
    }


 

No comments: