extjsextjs5

How to trigger Click event after associated interface has loaded for the first time only?


I want to make sure that a certain interface is loaded and displayed before i can trigger a click event on a button contained in that interface.

I am creating the interface using the following code :

   var mainV2 = Ext.create('widget.main', {
            renderTo: Ext.getBody(),
            hideMode: 'visibility',
           //Update
            listeners: {
              afterrender: function() {
                Ext.getCmp('#somebutton').fireEvent('click');
                        }
                 }
        });

        mainV2.show();

And firing the event right under the mentioned code

Ext.getCmp('#idcheckItem').fireEvent('click');

But it seems that the fireEvent is not affecting the button listener's. I was thinking because the call should be synchronous.

My question is how to make sure the mainV2 has loaded before firing the click event on the button only when mainV2 is called and displayed for the first time ?

Thanks for the great help.


Solution

  • You can create an afterRender method in the panels controller.

    Here is a fiddle

    This fiddle fires a buttons click event after the window is rendered. Be sure to put the afterRender method in the controller. I ran into some trouble when putting it directly on the panel.