-
13 Oct 2011 3:46 AM #1
controllers and views
controllers and views
I'm trying to create a basic mvc app with sencha touch 2. I have a few basic parts ready. The app.js and a controller, which load and run good. But all i need to do now is to add a view. But this is where the problem starts.
When i try to add a view to my controller, then it displays the following error in console:
I have no idea why i'm getting this error. As far as i can see i did exactly what the example apps are doing.GET file:///xcode/TEST_MVC/www/AM/view/User.js?_dc=1318501436195
Please take a look at my code:
This is my controller:
And this is my view:PHP Code:Ext.define('AM.controller.Main', {
extend: 'Ext.app.Controller',
views: ['User'], // <--- This is causing the error
init: function() {
this.control({
console.log("init");
});
},
});
So when i remove this line from my controller:PHP Code:Ext.define('AM.view.User' ,{
extend: 'Ext.Panel',
fullscreen: true,
html: 'dfgfahsg'
});
views: ['User']
Then my app runs fine, without errors... But that is how i try to 'add' my view to my controller.
For some reason it then looks in the "/AM/" folder, which is just the name i defined in app.js.
Anyone any idea what i'm doing wrong here...?
-
13 Oct 2011 6:25 AM #2
Just figured out i was still adding <script> references to my .js files. Which ofcourse isn't needed with sencha touch 2

Anyway, now i'm trying to load a panel (which are called Components now?) from a view. But it's not showing.
This is my app.js
This is my controller:Code:Ext.Loader.setConfig({ enabled: true }); Ext.application({ name: 'AM', appFolder: 'app', controllers: [ 'Main' ], launch: function() { Ext.create('Ext.viewport.Viewport', { fullscreen: true, items: { xtype: 'userlist' } }); } });
And this is my view:Code:Ext.define('AM.controller.Main', { extend: 'Ext.app.Controller', views : ['User'] });
Code:Ext.define('AM.view.User', { extend: 'Ext.Component', xtype: 'userlist', html: 'aafgvhfghfghfghfa' });
But for some reason the 'User' view isn't showing. I do see that my background has the faint grey tint, which indicates Sencha loaded succesfully.
But if i change the "items:" in app.js to this, then a panel renders just fine:
So my question basically is, how can i render a panel when it is in a separate file like i have now (User.js)???Code:... items: [ //xtype: 'userlist' xtype: 'panel', title: 'Users', html : 'List of users will go here' } ...
-
13 Oct 2011 6:41 AM #3
I am also facing this problem as posted here in the Q&A forum => http://www.sencha.com/forum/showthre...on-of-Tabpanel
-
13 Oct 2011 6:58 AM #4
Just looked at your example and noticed you're trying to load a tabPanel. So i changed my view to this:
Now when i launch my app then i DO see a toolbar at the top of my page, but i don't see the html content below that... So if anyone has any idea..Code:Ext.define('AM.view.User', { extend: 'Ext.TabPanel', xtype: 'userlist', items: [{ xtype: 'panel', html: 'djhfdsjk' }] });
-
13 Oct 2011 7:04 AM #5
Yeah I can only conclude its something to do with the xtype lookup not working correctly. I have an ExtJS 4 MVC app laid out in a similar manner which works fine, so I'm a bit stumped!
-
13 Oct 2011 7:57 AM #6Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 4
Vivendi, could you maybe zip up your app and post it? The easiest way for us to debug this is to get the exact same app (structure + code).
-
13 Oct 2011 9:58 AM #7
-
13 Oct 2011 10:32 AM #8
Vivendi - Hope you dont mind me butting in here, but see my attached app attached for you guys to debug, having same xtype related issues as mentioned in my earlier post on this thread.
-
13 Oct 2011 11:52 AM #9Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 4
I haven't tried the app yet, but I see you guys are not using the config object in the view definitions. Does the answer in this thread help fix the problem?
http://www.sencha.com/forum/showthre...on-of-Tabpanel
-
13 Oct 2011 11:56 AM #10
Yes, sorry I have posted in both forums with the same problem. Thanks again for your help here!


Reply With Quote

