Hybrid View
-
3 Apr 2012 5:08 AM #1
Unanswered: How to add view to viewport
Unanswered: How to add view to viewport
Hello,
I have following code.
This is my app.js fileCode:Ext.setup( { onReady : function() { var form = Ext.create('Ext.form.Panel', { fullscreen : true, items : [ { xtype : 'textfield', name : 'email', label : 'EMail', labelWidth : '35%' }, { xtype : 'passwordfield', name : 'password', label : 'Password', labelWidth : '35%' }, { xtype : 'button', text : 'Login', margin : '5 5 5 5', handler : function() { var values = form.getValues(); if (values.email == '') { Ext.Msg.alert('Alert', 'Email Address can not be empty.', Ext.emptyFn); }else{ // Call to home view } } }, { xtype : 'button', text : 'Forget Password', margin : '5 5 5 5', handler : function() { // Forget Password Clicked } } ] }); Ext.Viewport.add(form); } });
The following is index.html file.
and the following is home.js fileCode:<!DOCTYPE html> <html> <head> <title>MVC</title> <script type="text/javascript" src="lib/cordova-1.5.0.js"></script> <script type="text/javascript" src="lib/sencha/sencha-touch-all.js"></script> <link rel="stylesheet" href="lib/sencha/sencha-touch.css" /> <script type="text/javascript" src="app/app.js"></script> <script type="text/javascript" src="app/view/home.js"></script> </head> <body> </body> </html>
As you can see the app.js file has code line "// Call to home view". I want to add home.js screen there. how can I do that ? Please Help me.Code:var form1 = Ext.create('Ext.form.Panel', { fullscreen : true, xtype : 'homeview', items : [ { xtype : 'textfield', name : 'email', label : 'EMail', labelWidth : '35%' }, { xtype : 'passwordfield', name : 'password', label : 'Password', labelWidth : '35%' } ] });
-
3 Apr 2012 6:21 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
- Answers
- 3160
If you create a view with the fullscreen config set to true then it will automatically be added to Ext.Viewport. Optionally you can instead do Ext.Viewport.add(component);. This will only add the items, you still need to Ext.Viewport.setActiveItem(component); to make the component active.
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.
-
3 Apr 2012 9:47 PM #3
mitchellsimoens - I understand what you are saying , but suppose now I want to add view which is defined home.js as mentioned above how I create/add/show that view on the screen ?
-
4 Apr 2012 2:00 AM #4
Hej mitchellsimoens,
If you switch the javascript imports so that the home.js file is imported before your app.js file like so:
then it should be possible to write Ext.Viewport.setActiveItem(form1) in your app.js file to make the homescreen become visible.PHP Code:<script type="text/javascript" src="app/view/home.js"></script>
<script type="text/javascript" src="app/app.js"></script>
Best regards
-
4 Apr 2012 2:09 AM #5
Sn4k3 - I have tried with your example, now its not showing error but also not showing the home.js content. its showing blank page there.
Regards,
AvtarSingh Suchariya
-
4 Apr 2012 4:20 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
- Answers
- 3160
You should not include <script> tags, this is what Ext.Loader is for. If you require a class it will load the file.
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.


Reply With Quote