简体   繁体   中英

ExtJS: Uncaught TypeError: Cannot read property 'scope' of undefined

I've created a panel through this sample and it has 2 items under tools config. Both items have their own function which binds through ViewController . The refresh item's function is working pretty well but the gear item's function gives this error below;

Uncaught TypeError: Cannot read property 'scope' of undefined
    at constructor.addListener (Observable.js?_dc=1516015518102:1135)
    at constructor (Observable.js?_dc=1516015518102:403)
    at constructor.beforeInitConfig (Component.js?_dc=1516015518101:2261)
    at Ext.Configurator.configure (Configurator.js?_dc=1516015518102:558)
    at constructor.initConfig (Base.js?_dc=1516015518101:1554)
    at constructor (Component.js?_dc=1516015518101:2137)
    at new constructor (Class.js?_dc=1516015518101:42)
    at Object.widget (ClassManager.js?_dc=1516015518101:1638)
    at constructor.create (ComponentManager.js?_dc=1516015518102:76)
    at constructor.lookupComponent (Container.js?_dc=1516015518101:1564)

I've moved the view class from app folder to classic folder but ViewController class stays in app folder so I guess that error is raising up through this notation. How should I declare it within ViewController?

weatherWindow: function () {
        var win = this.lookupReference('weatherWindow');

        if (!win) {
            win = new MyApp.view.weather.SettingsWindow();
            this.getView().add(win);
        }

        win.show();
    },

UPDATE I've created a ViewController for the view but still gives scope error!

Ext.define('MyApp.view.dash.WeatherView', {
    extend: 'Ext.panel.Panel',
    xtype: 'weatherview',

    requires: [
        'MyApp.view.dash.WeatherViewVC',

    ],

    controller: 'weatherView',

//and..
Ext.define('MyApp.view.dash.WeatherViewVC', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.weatherView',

    requires: [],

    weatherWindow: function () {
        debugger;

        var win = this.lookupReference('settingsWindow');

        if (!win) {
            win = new MyApp.view.weather.SettingsWindow();
            this.getView().add(win);
        }

        win.show();
    },

I've found a solution for this error. Created a function within window class and return it;

getSettingsItems: function () {
    var me = this;

    var settingsItems = [
        // whole items listed here!
    ];

    return settingsItems;
},

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM