PDA

View Full Version : Uncaught TypeError: Cannot call method 'show' of undefined



dsultanov
10 Jul 2013, 11:53 PM
I do not understand why this.getNewuserwindow (); is undefined, as a result I get the error: Uncaught TypeError: Cannot call method 'show' of undefined



Ext.define('ReportsApp.controller.AdminPanelControl', {
extend: 'Ext.app.Controller',
views: [
'report.AdminPanel',
'report.AdminPanelGrid',
'report.newUserWindow',
'report.newUserForm'
],
stores: ['AdminPanelStore'],
refs: [{ref: 'newuserwindow', selector: 'newUserWindow'}
],
init: function() {
this.control({
'#deleteUser': {
click: this.onRemoveClick
},
'#addUser': {
click: this.onAddClick
},
'#cancel': {
click: this.onCancelClick
}


});
},
onAddClick: function() {

var store = Ext.getStore('AdminPanelStore');
var rec = store.getProxy().getModel().create();

var nuw = this.getNewuserwindow();

nuw.show();

},
onCancelClick: function() {

},
userEdit: function(rec) {

}

});

julio.batista
11 Jul 2013, 2:43 AM
Do you have this component created?
Try this too


ref: 'newuserwindow',
selector: 'viewport newUserWindow'

dsultanov
11 Jul 2013, 3:00 AM
No, I simply identified:


Ext.define('ReportsApp.view.report.newUserWindow', {
extend: 'Ext.window.Window',
alias: 'widget.newUserWindow',
frame: true,
title: '?????????? ?????? ????????????',
width: 330,
closable: false,
items: Ext.create("ReportsApp.view.report.newUserForm")
});

but even if I am writing nuw.create (); then still get: Uncaught TypeError: Cannot call method 'create' of undefined

p.s. selector: 'viewport newUserWindow' did not solve the problem

julio.batista
11 Jul 2013, 3:12 AM
If I'm not wrong, according to the docs http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.app.Controller-cfg-refs refs are used to reference elements on page, it means they must be created to be referenced.

dsultanov
12 Jul 2013, 2:23 AM
Thanks!