简体   繁体   English

未捕获的TypeError:对象[object Object]没有方法'onAdded'

[英]Uncaught TypeError: Object [object Object] has no method 'onAdded'

I am using ExtJS4 with Java servlets. 我将ExtJS4与Java servlet一起使用。 I am following the MVC architecture for ExtJS. 我正在使用ExtJS的MVC体系结构。 I am trying a simple example of displaying a border layout but it doesnt work and I get the following error in ext-all.js in the javascript console: 我正在尝试显示边框布局的简单示例,但是它不起作用,并且在javascript控制台的ext-all.js中收到以下错误:

Uncaught TypeError: Object [object Object] has no method 'onAdded' 未捕获的TypeError:对象[object Object]没有方法'onAdded'

Here is my code: 这是我的代码:

app.js app.js

Ext.Loader.setConfig({   
 enabled : true
});
Ext.application({
name : 'IN',
appFolder : 'app',
controllers : [ 'Items' ],
launch : function() {
    console.log('in LAUNCH-appjs');
    Ext.create('Ext.container.Viewport', {
        items : [ {
            xtype : 'borderlyt'
        } ]
    });
}
});

Items.js (controller) Items.js(控制器)

Ext.define('IN.controller.Items', {    
extend : 'Ext.app.Controller',
views : [ 'item.Border' ],
init : function() {
    this.control({
        'viewport > panel' : {
            render : this.onPanelRendered
        }
    });
},
onPanelRendered : function() {
    console.log('The panel was rendered');
}
});

Border.js (view) Border.js(查看)

Ext.define('IN.view.item.Border',{extend : 'Ext.layout.container.Border',
alias : 'widget.borderlyt',
title : 'Border layout' ,
autoShow : true,
renderTo : Ext.getBody(),
defaults : {
            split : true,
            layout : 'border',
            autoScroll : true,
            height : 800,
            width : 500
        },
        items : [ {
            region : 'north',
            html : "Header here..",
            id : 'mainHeader'
        }, {
            region : 'west',
            width : 140,
            html : "Its West..",
        }, {
            region : 'south',
            html : "This is my temp footer content",
            height : 30,
            margins : '0 5 5 5',
            bodyPadding : 2,
            id : 'mainFooter'
        }, {
            id : 'mainContent',
            collapsible : false,
            region : 'center',
            margins : '5',
            border : true,
        } ]
 });

The folder structure for the Webcontent is as follows: Webcontent的文件夹结构如下:

  • WebContent 网页内容
    • app 应用程式
      • controller 控制者
        • Items.js Items.js
      • model 模型
      • store 商店
      • view 视图
        • item 项目
          • Border.js Border.js
    • ext_js ext_js
      • resources 资源
      • src src
      • ext_all.js ext_all.js
    • index.html index.html
    • app.js app.js

Can someone help me resolve this error? 有人可以帮助我解决此错误吗?

Thanks in advance 提前致谢

Ext.define must not contain configuration option renderTo . Ext.define不得包含配置选项renderTo When components are loaded the body may still not exist. 加载组件后,主体可能仍然不存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM