-
29 Dec 2012 7:01 PM #1
Dynamic Creation of View Works In Development, Not In Test
Dynamic Creation of View Works In Development, Not In Test
I have a function in the controller that looks like this:
It simply takes a view name, and creates it and adds it to a card layout. This works fine in my development directory. When I build this in to a test and the code is compiled in to one file, it doesn't work. There are no errors thrown, it simply does not show the view. In stepping through the code, the view is created and added to the card panel, so I know all the code is in the build. Any ideas?Code:loadView : function(viewName) { var view = Ext.create('TOMobile.view.' + viewName); TOMobile.MainContent.removeAll(true); TOMobile.MainContent.add([view]); var lastid = TOMobile.MainContent.getItems().length - 1; TOMobile.MainContent.setActiveItem(lastid); }
-
31 Dec 2012 6:58 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,710
- Vote Rating
- 436
Inspect the DOM to see if it, it's parent and it's child items are sized properly.
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.
-
31 Dec 2012 7:39 PM #3
Thanks, that was good advice! After quite a bit of manual DOM traversal, I found the difference in the computed DOMs of development and test. In test, this DOM element exist:
but, in the generated test app, it looks like this:Code:<div class="x-container x-layout-box-item x-flexed x-sized" id="ext-main-1" style="-webkit-box-flex: 1;">
The most important part being the absence of style="-webkit-box-flex: 1;". If I manually add this in to the test site's DOM, the view appears. I am now focusing on why this CSS doesn't get inserted in the test site.Code:<div class="x-container x-layout-box-item x-stretched" id="ext-main-1">
-
6 Jan 2013 11:52 AM #4
After much debugging, I found the answer. I had to move the flex attribute on the main card layout in to the config property. So, it went from this:
to this:Code:Ext.define('TOMobile.view.MainContent', { extend : 'Ext.Container', xtype : 'main', flex : 1, config : { layout : 'card', items : [] } });
I am still not sure why it worked in development and not in the build. Also, I would like to say that I have had lots of problems figuring out if things worked better in the config property or at the top level. It has gone both ways.Code:Ext.define('TOMobile.view.MainContent', { extend : 'Ext.Container', xtype : 'main', config : { flex : 1, layout : 'card', items : [] } });


Reply With Quote