问题描述:

I am new to extjs.I tried to write a simple application with MVC architecture as described here :

http://docs-origin.sencha.com/extjs/4.2.1

When I try to run the application in browser I give this error in firebug:

"NetworkError: 404 Not Found - http://127.0.0.1/Sample/app/view/userlist.js?_dc=1408194279243"

My project structured is :

List.js file :

/**

* Created by Sina-PC on 8/14/14.

*/

Ext.define('Sample.view.users.List' ,{

extend: 'Ext.grid.Panel',

alias: 'widget.userlist',

title: 'All Users',

initComponent: function() {

this.store = {

fields: ['name', 'email'],

data : [

{name: 'Ed', email: '[email protected]'},

{name: 'Tommy', email: '[email protected]'}

]

};

this.columns = [

{header: 'Name', dataIndex: 'name', flex: 1},

{header: 'Email', dataIndex: 'email', flex: 1}

];

this.callParent(arguments);

}

});

Users.js file:

Ext.define('Sample.controller.Users', {

extend: 'Ext.app.Controller',

views:['userlist'],

init: function() {

console.log('Initzed Users! This happens before the Application launch function is called');

this.control({

'viewport > panel': {

render: this.onPanelRendered

}

});

}

,

onPanelRendered: function() {

console.log('The panel was rendered');

}

});/**

* Created by Sina-PC on 8/14/14.

*/

app.js file :

Ext.application({

name: 'Sample',

appFolder:'app',

controllers:[

'Users'

],

launch: function() {

Ext.create('Ext.container.Viewport', {

layout: 'fit',

items: [

{

xtype: 'userlist'

}

]

});

}

});

and index.html:

<html>

<head>

<title>Hello Ext</title>

<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css">

<script type="text/javascript" src="extjs/ext-all-debug.js"></script>

<script type="text/javascript" src="app.js"></script>

</head>

<body></body>

</html>

网友答案:

ExtJs doesn't know what is a view 'userlist'. You must add to requires this file.

Ext.define('Sample.controller.Users', {

requires: [ 'Sample.view.users.List' ],

...
网友答案:

Users.js file has "views:['userlist']," and it should be "views:['Sample.view.users.List'],"

相关阅读:
Top