I am programming a Sencha Touch application with a moderately complex composition Ext.TabBar with Ext.Panel inside it.
But my Ext.Panel using Ext.layout.CardLayout works in a mysterious problem if the fullscreen: true property is not set on it fullscreen: true : it throws TypeError: Object card has no method 'setActiveItem' when I try to call the panel .setActiveItem() method This is not in my proof of the concept version in which fullscreen: true is included.
I can replicate the issue on the Chrome console on the Sencha Touch library page loaded as follows:
> var p1 = new Ext.Panel({layout:'card', items:[{html:'a'},{html:'b'}]}) undefined > p1.setActiveItem(0) TypeError: Object card has no method 'setActiveItem'
And this does not happen with the .fullscreen property:
> var p2 = new Ext.Panel({fullscreen: true, layout:'card', items:[{html:'a'},{html:'b'}]}) undefined > p2.setActiveItem(0) subclass
What gives?
Version Information: I am using Sencha Touch 1.0.1a
Update 1 (January 3, ~ 10.30UTC + 1h), switching with the debugger and detecting things:
Just setting layout: 'card' will not lead to the creation of a real Ext.layout.CardLayout object created for the real one. Because .setActiveItem() tries to delegate the compent .layout property, it will crash almost instantly. However, installing .layout in the new Ext.layout.CardLayout causes more problems in the line.
Update 2 : (January 3, ~ 12: 25UTC + 1h) It all comes down to various component objects that are not rendered / added to the dependency in order to be ready for rendering. I managed to get my code to work by adding listeners, first the listener for the added event on the application panel, which has this.setLayout(new Ext.layout.CardLayout()); and then the afterrender listener of the component afterrender added, which finally calls .setActiveItem() to switch to the desired map.