PDA

View Full Version : "TypeError: item.onAdded is not a function" when adding component to container.



xjscrafter
20 May 2014, 12:07 PM
I am trying to create a framework UI that creates container contents based on configs, and I get an error "TypeError: item.onAdded is not a function".

This does not happen in my smaller test app, but it does happen in our actual app. Can't figure out why.

Here is some partial code.

Ext.define('atlas.screen.Viewport', {
extend: 'Ext.container.Viewport',
alias: 'widget.atlas.Viewport',


autoScroll: true,
layout: 'fit',


requires: [
'base.framework.MainAppView',
'base.framework.MainAppNavigation'
],


items: [{
// MainAppView requires providing config with items to populate the north,
// west, and center regions.
xtype: 'mainAppView',
westItems: [{
xtype: 'mainAppNavigation'
}]
}]
});

Ext.define('base.framework.MainAppView', {
extend: 'Ext.container.Container',
alias: 'widget.mainAppView',


requires: ['base.util.CommonBaseUtil'],


autoScroll: true,
layout: 'border',


westItems: null,


initComponent: function() {
var me = this;


Ext.applyIf(me, {
items: [{
xtype: 'container',
itemId: 'appWestContainer',
region: 'west',
width: 85,
items: me.westItems,
hidden: true,
listeners: {
afterrender: CommonBaseUtil.showHide
}
}]
});
me.callParent(arguments);
},


applyWestItems: function(westItems) {
this.down('#appWestContainer').add(westItems);
}
});

Ext.define('base.framework.MainAppNavigation', {
extends: 'Ext.container.Container',


alias: 'widget.mainAppNavigation',


initComponent: function() {
var me = this;


Ext.applyIf(me, {
items: [{
xtype: 'button',
itemId: 'myButton',
text: 'test'
}]
});
me.callParent(arguments);
}
});

xjscrafter
20 May 2014, 3:59 PM
It was one of my favorite BS ExtJS issues, "extends" VS "extend". You would think Sencha Cmd could catch this.