Search code examples
javascriptextjsviewcontrollerextjs6-classicextjs6.2

How to create a base Ext.app.ViewController common to other view controllers?


I want to create an base ViewController for all other controllers used in an ExtJS app.

The problem is that ExtJs is looking for the base class in /classic/src/view instead of /app/view....

Here is an example: in /app/view/base/BaseController.js

Ext.define('myApp.view.base.BaseController', {
    extend: 'Ext.app.ViewController',

    doStuff: function(msg) {
        alert(msg);
    }
});

in /app/view/another/AnotherController.js

Ext.define('myApp.view.another.AnotherController', {
    extend: 'myApp.view.base.BaseController',

    onButtonClick: function() {
        doStuff('Button clicked');
    }
});

in /app/classic/src/view/another/Another.js

Ext.define('myApp.view.another.Another', {
    extend: 'Ext.panel.Panel',
    xtype: 'another',
    alias: 'view.another',
    id: 'panel_another',

    controller: 'another',
    items: [{
        xtype: 'button',
        text: 'The Button',
        handler: onButtonClick
    }]
});

However when i run the app, ExtJs throws an error saying that /classic/src/view/base/BaseController.js was not found!

What am i doing wrong here?

Thank you for your time, and for your help!


Solution

  • You just try building your app by sencha app build.It will solve this issue.