Question

I'm developping an Extjs app. Here is one of my controllers

Ext.define('ACP.controller.CodeTabs', {
extend: 'Ext.app.Controller',

/*
views: [
    'CodeTabs'
],
*/

refs: [
    {
        ref: 'codetabs',
        selector: 'codetabs',
    }
],

init: function() {
    this.application.on({
        addtab: this.addTab,
        closetab: this.closeTab,
    });
},

addTab: function() {
    var tabs = this.getCodetabs();
    tabs.add(
        {
            title: 'New tab',
            iconCls: 'tabs',
            html: 'VICTORY',
        }
    ).show();
},

closeTab: function() {
    alert("closetab");
},
});

An here is the related view:

Ext.define('ACP.view.CodeTabs', {
extend: 'Ext.tab.Panel',
alias: 'widget.codetabs',
layout: 'fit',
items: [
    {
        title: 'Test',
        html: 'HELLO ASLAN'
    }
],
});

The problem is that the getter this.getCodetabs() is undefined. Isn't it supposed to be autogenerated by refs ? What am I doing wrong ?

Here is my application : http://atomcodepad.com/acp You can try to click on the "addtab" button to see my problem happening.

Was it helpful?

Solution

You're in the scope of the Application, not the Controller where the ref is defined. Use the getController(name) method to get a reference to the controller, from there your getter is defined.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top