PDA

View Full Version : Has anyone gotten this to work



profunctional
2 Oct 2011, 6:17 AM
http://www.sencha.com/blog/sencha-touch-optimizing-memory-usage/

I (http://www.sencha.com/blog/sencha-touch-optimizing-memory-usage/) followed it and the methods like setCard don't even exist. Is this deprecated or something???

bassjobsen
2 Oct 2011, 6:31 AM
Hi,

Can you change your subject to something like "sencha touch optimizing memory usage"?

Regards,

Bass

profunctional
2 Oct 2011, 7:00 AM
too late.

bassjobsen
2 Oct 2011, 12:03 PM
Hi,

setCard is a method of Ext.tab.Tab

I wonder if removing content from the DOM in most cases not will reduce preformance when switching panels.

Best regards,

Bass

profunctional
2 Oct 2011, 1:31 PM
I Need to destroy one time use panels. For instance a registration form panel. But for core app panels I wouldn't destroy.

bassjobsen
2 Oct 2011, 3:10 PM
Hi,

There are more threads like yours:
1) http://www.sencha.com/forum/showthread.php?107624-Card-Layout-setCard-vs.-setActiveItem
2) http://www.sencha.com/forum/showthread.php?147857-Error-when-discarding-OldCard-on-CardSwitch-event

In the first the second post is an example which should work. I tried and it won't.
The example works when i replace setCard with setActiveItem

I also think you should use panel.on('cardswitch', function(id, newCard, oldCard) in stead of panel.on('cardswitch', function(newCard, oldCard)

Together this works for me:

Ext.setup( {
onReady: function() {

var panel = new Ext.Panel({
id: 'keyboards',
layout: 'card',
fullscreen: true,
items:[{
xtype: 'container',
id: 'kb1',
items: [{
xtype: 'button',
text: 'Show kb2',
handler: function() {
Ext.getCmp('keyboards').setActiveItem('kb2'); // works fine
}
}]
},{
xtype: 'container',
id: 'kb2',
items: [{
xtype: 'button',
text: 'Show kb1',
handler: function() {
Ext.getCmp('keyboards').setActiveItem('kb1'); // works fine
}
}]
}]
})

panel.on('cardswitch', function(id, newCard, oldCard) {
console.log('old: ' + oldCard.id);
console.log('new: ' + newCard.id);
if (oldCard) {
this.remove(oldCard, true);
}
}, panel);

panel.show();
}

});