Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJS lookupReference not working

Tags:

extjs

extjs6

I'm tring to use lookReference in my ViewController but I can't get the element.

Here is my view:

Ext.define('MyApp.view.main.Main', {
    extend: 'Ext.container.Container',
    xtype: 'app-main',
    requires: [
        'Ext.layout.container.Card',
        'Ext.layout.container.Border',
        'Ext.layout.container.Accordion',
        'Ext.form.Label',
        'MyApp.view.security.LoginForm'
    ],

    controller: 'main',
    reference: 'appmain',


    items: [{xtype: 'loginform', height: 330}]
});

My LoginForm view is:

Ext.define('MyApp.view.security.LoginForm', {
    extend: 'Ext.form.Panel'
    title: 'Access',
    items: [
    {
        name: 'userName',
        fieldLabel: "User Name"
    }, {
        inputType: 'password',
        name: 'password',
        fieldLabel: "Password"
    }],
    buttons: [{
        text: 'Log in',
        listeners: {
            click: 'onLoginClick'
        }

    }]
});

And this is my ViewController:

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

    alias: 'controller.main',

    onLoginClick: function(button, e, options) {
        var me = this;

        // show application layout
        var main = me.lookupReference('appmain');

        // HERE main IS NULL... WHY?
    }
});

Any clue what Im doing wrong?

like image 317
VAAA Avatar asked Mar 12 '23 02:03

VAAA


1 Answers

A reference is stored on the structure (component/controller) above the current one. It doesn't make sense to put a reference on the component that has the controller, since it's already accessible via this.getView().

like image 183
Evan Trimboli Avatar answered Apr 26 '23 08:04

Evan Trimboli