PDA

View Full Version : problem with Extjs 4.1 documentation



nimaous
18 May 2012, 12:04 PM
Hi
Im new to Extjs 4.1

when I add
controllers:['Users'],
to my app.js I got this error :
Uncaught TypeError: Object Ext.container.Viewport has no method 'push'

I read some where to add
require : AM.controller.Users
so I added this line :
requires:['Ext.container.Viewport',AM.controller.Users],
to my app.js
but I got this error
Uncaught Error: Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. Missing required class: AM.controller.Users

below are my related files

my controller/Users.js file

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

extend :'Ext.app.Controller',

init :function(){
console.log("initilize users");
}

});

and my app.js file

Ext.application({
requires:['Ext.container.Viewport','AM.controller.Users'],
name: 'AM',
appFolder :'app',

controllers:['Users'],


launch: function () {

Ext.create('Ext.container.Viewport' , {
layout :'fit',
items: [
{
xtype :'panel',
title :'Users',
html :'List of user will go here '
}
]
});
}

vietits
18 May 2012, 3:41 PM
Try to enable dynamic class loading by setting enabled of Ext.Loader to true


Ext.Loader.setConfig({
enabled: true,
...
});

nimaous
18 May 2012, 8:52 PM
tnx for your replay

I add

Ext.Loader.setConfig({
enabled: true,
path:{
'Ext':'extjs-4.1.0/src',
'AM' :'app'
}

});


Ext.require([
'Ext.container.Viewport',
'AM.controller.Users',

]

but I got this error :

GET file:///home/nima/Aptana%20Studio%203%20Workspace/js.ext/AM/AM/controller/Users.js?_dc=1337402645080




It seems loader can not load my AM.controller.Users

my project file organization :
AM

app
index.html
app.js
my app folder contains controller folder which contains Users.js

vietits
19 May 2012, 12:12 AM
It seems that you have an typo in declaring the fullname of Users controller. Try to fix it as below:


Ext.define('AM.controller.Users' , {
...
});

nimaous
19 May 2012, 5:11 AM
Hmmmmmmmmmm/:):">

tnx alot :D

snotll
23 May 2012, 10:29 AM
I received the same error (... no method 'push') and solved it by putting the requires value in brackets:

Ext.application({
requires: ['Ext.container.Viewport'],
name: 'AM',
appFolder: 'app',
controllers : ['Users'],

launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [
{
xtype: 'panel',
title: 'Users',
html : 'List of users will go here'
}
]
});
}
});

Hope that helps.

kristiantolie
25 May 2012, 10:58 PM
Thank you

damianob
7 Jun 2012, 8:24 AM
This solution worked for me. Thanks. I noticed that the documentation in the download does not include the brackets, but the documentation online does. It's probably a good idea to use the online docs since they are different.

hgs
29 Jul 2012, 7:42 PM
Thank you for this thread, it is very frustrating as a noob trying to work through your first ext js application by pasting in the examples when they don't work as written. Adding the line below fixed it for me too:

Ext.Loader.setConfig({ enabled: true });