-
13 Oct 2011 12:49 AM #1
Answered: ExtJS4 to ST2
Answered: ExtJS4 to ST2
Hi, i'm trying to port the ExtJS mvc tutorial to Sencha Touch 2. But i'm having some problems. I'm following this tutorial:
docs.sencha.com/ext-js/4-0/#/guide/application_architecture/
Somewhere in the beginning it says i have to create my app.js file and add the following code in it:
But it then complains with the following error:PHP Code:Ext.application({
name: 'TT',
appFolder: 'app',
launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [
{
xtype: 'panel',
title: 'Main',
html : 'Blaat'
}
]
});
}
});
So i added this to the top of the code:
But now it says the following:Code:Ext.Loader.setConfig({ enabled: true });
XMLHttpRequest cannot load file:///projects/xcode4/Sencha2/www/container/Viewport.js?_dc=1318495537750. Cross origin requests are only supported for HTTP.
Uncaught TypeError: object is not a function
So it looks like it's trying to create Viewport.js somewhere in "www/container/Viewport.js" But obviously that doesn't exist and should not exist. Anyone any idea how to fix this error?
-
Best Answer Posted by mitchellsimoens
You should not use Ext.Viewport directly in ST2. If you have a Viewport.js (and class name of app.view.Viewport) file in the app/view/ folder then the app will automatically create that Viewport.js class.
The Viewport class in ST2 will always be there and if you specify something with fullscreen as true, it will be added as an item to the Viewport singleton.
-
13 Oct 2011 12:56 AM #2
Just another thing, i also tried to change 'Ext.container.Viewport' to 'Ext.Viewport', but that didn't worked either.
I also tried to lookup Viewport in the documentation. But when i try to open it just shows me a spinner. It never really shows the documentation about Viewport... Perhaps it's missing?
http://dev.sencha.com/deploy/touch/docs/
- edit -
Looked it up using the search function from this page:
http://docs.sencha.com/touch/2-0/#!/...wport.Viewport
So it had to be 'Ext.viewport.Viewport'. But now it renders a blank page (no errors)... I guess i should see atleaat a panel with some html text on it right?
-
13 Oct 2011 3:24 AM #3
Changed layout: 'fit' to fullscreen and now it seems to be working
-
13 Oct 2011 6:42 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
You should not use Ext.Viewport directly in ST2. If you have a Viewport.js (and class name of app.view.Viewport) file in the app/view/ folder then the app will automatically create that Viewport.js class.
The Viewport class in ST2 will always be there and if you specify something with fullscreen as true, it will be added as an item to the Viewport singleton.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
13 Oct 2011 8:12 AM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
This is one of the things that will be clarified
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
10 Nov 2011 12:22 AM #6
Apologies for necroing a thread a month old but would it be possible to clarify your post Mitchell? I have a file named Viewport.js in the app/view directory, but I keep getting a blank screen. I checked the documentation on viewports in ST2 but I couldn't find anything useful.
Is it possible to show us some simple example of how the app/view/Viewport.js file might look like?
Thanks,Code:Ext.define('App4Cards.view.Viewport', { extend : 'Ext.viewport.Viewport', layout : 'fullscreen', initComponent : function() { console.log('Viewport:initComponent'); this.items = [ { xtype : 'tabpanel', fullscreen : true, tabBarPosition : 'bottom', items : [ { title : 'Home', iconCls : 'home', html : 'Home Screen' }, { title : 'Contact', iconCls : 'user', html : 'Contact Screen' } ] } ], this.callParent(); } });
Jurian.Last edited by Jurian Baas; 10 Nov 2011 at 12:33 AM. Reason: Added own code for clarification
-
10 Nov 2011 4:12 AM #7Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
This is one of the confusing things of Sencha Touch 2 I will admit but you don't extend Ext.viewport.Viewport. Ext.viewport.Viewport is a singleton that will always be created and almost everything gets added to it. You need to extend Ext.Panel or Ext.Container for your app's Viewport class and put fullscreen to true on that. Any class with fullscreen will be added to that global Ext.viewport.Viewport instance.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
10 Nov 2011 7:44 AM #8
In the docs for Sencha Touch 2 the fullscreen config is marked as deprecated and it says that Ext.Viewport.add() should be used instead - http://docs.sencha.com/touch/2-0/#!/...-cfg-fullscren
So is it okay to rely on Ext.Viewport as the main container for the app and manipulate with items in it, i.e. add and remove components when necessary?Eugene
Ext.Direct for ASP.NET MVC


Reply With Quote