-
23 Nov 2011 6:26 AM #1
Ext.tab.Panel listeners error
Ext.tab.Panel listeners error
U]REQUIRED INFORMATION[/U]Ext version tested:
- Sencha Touch 2.0PR2
- Chrome 11 (Windows)
- tab panel event listeners error.
- Create Ext.tab.Panel which contains two same child (xtype: 'child')
- Override initialize method of Child panel, and alert some informations, strange!!
- false
- true
- id: child1
- false
- false
- id: child1
- id: child1
Code:Ext.setup({ onReady : function() { // child Ext.define('Child', { extend: 'Ext.Container', xtype: 'child', config: { items: [{ xtype: 'sliderfield', label: 'Single Thumb' }, { xtype: 'togglefield', label: 'Toggle Thumbs' }] }, initialize: function() { alert('is hidden? ' + this.isHidden()); this.on('show', function(cmp) { alert('id: ' + cmp.getId()); }) } }); // Tab Panel Ext.define('MyTanPanel', { extend: 'Ext.tab.Panel', config: { tabBarPosition: 'top', items: [{ title: 'child1', xtype: 'child', id: 'child1' }, { title: 'child2', xtype: 'child', id: 'child2' }] } }); Ext.create('MyTanPanel').show(); } });
-
23 Nov 2011 12:19 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,637
- Vote Rating
- 435
You have overridden the initialize method which is used internally. You must do this.callParent(arguments); in order to keep the functionality the framework may have in internally used methods.
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.
-
23 Nov 2011 5:39 PM #3
I changed my code as you said, still alert the same information:
false, false, id:child1, id:child1.
Code:// child Ext.define('Child', { extend: 'Ext.Container', xtype: 'child', config: { items: [{ xtype: 'sliderfield', label: 'Single Thumb' }, { xtype: 'togglefield', label: 'Toggle Thumbs' }] }, initialize: function() { this.callParent(arguments); alert('is hidden? ' + this.isHidden()); this.on('show', function(cmp) { alert('id: ' + cmp.getId()); }) } }); // Tab Panel Ext.define('MyTanPanel', { extend: 'Ext.tab.Panel', config: { tabBarPosition: 'top', items: [{ title: 'child1', xtype: 'child', id: 'child1' }, { title: 'child2', xtype: 'child', id: 'child2' }] } }); // Main Ext.setup({ onReady : function() { Ext.create('MyTanPanel').show(); } });
-
10 Jan 2012 4:22 PM #4Sencha - Sencha Touch Dev Team
- Join Date
- Jul 2009
- Location
- Palo Alto, California
- Posts
- 469
- Vote Rating
- 9
The observed result is correct, here's why:
When the 2 'Child' tab is instantiated, their initialize() method gets called. At that moment, they're not hidden (since their 'hidden' config is not explicitly set to 'true'). That's why you see 2 'is hidden? false' alerts.
After they're fully instantiated and are added into the 'MyTanPanel' container, the container has a 'card' layout by default, which will hide all the cards right after they're added to the container.
Finally, the 'card' layout activate the active card, and that's when the 'show' event is fired on the first child.
To reliably get informed about the visibility state of components, listen to both 'show' and 'hide' events instead.Sencha Touch Lead Architect
-
10 Jan 2012 6:19 PM #5
I know, thank you very much.
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote