PDA

View Full Version : setcard failing when id is given to panel.



blessan
26 Jul 2010, 12:38 AM
I tried creating a panel with the card layout. Initially the card has no item. So I added a resize listener to the panel and in that I made a new panel and slide that in using the setCard method.

Now I have a button in my panel which should slide in the previous panel. Its sort of like the home button. But it does not work when my panel has an id. When I remove it, t works fine. Does setCard write the new panel into the dom.

How can set the card without always writing into the dom. I tried setActiveItem but it didnt work.



Ext.setup({
icon: 'icon.png',
db:null,
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
glossOnIcon: false,
onReady: function() {
var mainPanel=new Ext.Panel({
fullscreen:true,
scroll: 'none',
id:'mainContainer',
layout:'card',
activeItem:0,
items:[
{
xtype:'panel',
id:'innerContainer',
layout:'card',
style:'background-color:black;',
fullscreen:true,
items:[],
listeners: {
"resize":function() {
panelRequester('homepanel');
}
}
}
],
dockedItems: [
{
xtype: 'toolbar',
dock: 'top',
id:'main_top_toolbar',
title:'UBook24-7.com',
layout: {
pack: 'justify',
align: 'center' // align center is the default
},
items: [
{
xtype: 'button',
ui: 'normal',
text: '',
baseCls:'ubHomeButton',
maxWidth:40,
maxHeight:40,
minWidth:40,
minHeight:40,
handler: function() {
panelRequester('homepanel');
}
},
{xtype: 'component', flex: 1}
]
}
]
});

if (Ext.platform.isPhone||Ext.platform.isTablet) {
mainPanel.fullscreen = true;
} else {
Ext.apply(mainPanel, {
fullscreen: true,
floating: true,
modal: false,
centered: true,
hideOnMaskTap: false,
autoWidth:true,
autoHeight:true
});
}
mainPanel.show();
}

}
);

panelRequester = function(panel) {
Ext.Ajax.request({
url: 'panelStructure.php',
method: 'POST',
params: {
panelName: panel
},
success: function(responseObject) {
var data = Ext.decode(responseObject.responseText);
console.info(eval(data));
newPanel = eval(data);
innerContainer = Ext.getCmp('innerContainer');
if(panel == 'homepanel') {
innerContainer.setCard(newPanel);
} else {
innerContainer.setCard(newPanel, {type:'slide',direction:'left'});
}
},
failure: function(responseObject) {
var data = Ext.decode(responseObject.responseText);
console.info("Error",data);
},
scope: this
});
}