View Full Version : Good practice: how to interconnect controllers and views and such?

9 Aug 2012, 11:56 AM
The simplest version of this question is the following: how should a controller obtain and retain a reference to its view? Currently, I've got Ext.ComponentManager.get() calls here and there, but I wonder if there is any convention for obtaining these in the init() function and just hanging onto them?

9 Aug 2012, 12:10 PM
See the "Using Refs" section this page:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.app.Controller (http://docs.sencha.com/ext-js/4-1/#%21/api/Ext.app.Controller)

You don't need to hold on to the references, just add the selectors to the refs array like in the example:

ref: 'list',
selector: 'grid'

And when you need a reference use this:

refreshGrid: function() {
this.getList() ...