chriscrossweb
chriscrossweb

Reputation: 348

How to run conroller methods within a event in Ext JS 4.2 (Sencha Architect)

I have in Architect the following structure.

A controller that includes a view (example MyPanelView)

In the MyPanelView, you can have a button, and give it an itemId. Then you can bind it to a click event. You can use the click event (inline) without the controller, or you can move the event to the controller. That works fine.

But what about these events? afterrender, beforerender, etc..? If you move this up to the controller, the event does not get fired there.

Since this is not working, how could I acces the controller methods within the afterrender function of the panel?

onAfterrenderMyPanelView : function(component, eOpts) {
   this.getRefToOtherPanel() //not working
}

Thanks in advance! I'm lost..

Chris.

Upvotes: 1

Views: 473

Answers (1)

James
James

Reputation: 4152

You can set up listeners and event handlers in your controller like this (example from the Sencha docs):

 Ext.define('MyApp.controller.Users', {
     extend: 'Ext.app.Controller',

     init: function() {
         this.control({
             'viewport > panel': { //<-- ComponentQuery
                 render: this.onPanelRendered //<-- event handler
             }
         });
     },

     onPanelRendered: function() {
         console.log('The panel was rendered');
     }
 });

Upvotes: 1

Related Questions