View Full Version : [DUP] Not possible to set listeners on the defined view class.

16 Apr 2014, 6:31 AM
I create a new project to check the error. I'm not sure if it is a bug or not, but it annoys me not being able to set listeners on a defined class. The workaround I use is using a container for the original component I'd like to set the listeners, but that sucks, because I need to use an extra panel.
Here is the code of my view:

Ext.define('Foo.view.main.Main', {
extend: 'Ext.container.Container',

xtype: 'app-main',

controller: 'main',
viewModel: {
type: 'main'

layout: {
type: 'border'

listeners: {
render: 'onContainerRender'

The code from the controller:

Ext.define('Foo.view.main.MainController', {
extend: 'Ext.app.ViewController',

alias: 'controller.main',

onContainerRender: function() {
console.log('it fails!')

The firebug output:

TypeError: scope is null

fn = scope[fn];

Can anyone point if I'm doing something wrong or if it is a bug?

16 Apr 2014, 7:21 AM
Do you have the main ViewModel class?

16 Apr 2014, 7:45 AM
Essentially a dupe of this thread:


In the next beta release, there will be 2 special scope options for dealing with this.

You can specify:

scope: 'this', which means the scope will only ever attempt to resolve to the view.
scope: 'controller', which means the scope will only ever attempt to resolve to a directly attached view controller.

Everything else will use the normal scope resolution methods. The reasoning is discussed in the other thread.

16 Apr 2014, 7:59 AM
Thanks evant