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?
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()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With