PDA

View Full Version : Trouble showing/hiding TabPanelItem



haibijon
18 Apr 2007, 5:49 PM
Alright, I must be doing something really dumb here, I can't seem to get this working, and I know I've done it before.

I lazy-load the panel when Freya.Messages.show() is called, and then once the panel is shown it can be hidden by either the close box on the tab, or by calling Freya.Messages.hide(). Calling the show method works just fine, but once the panel is closed it cannot be brought back. Any help/suggestions? Am I just missing something dumb?


Freya.Messages = function(){
var tb, panel, parentLayout;

var t = new Ext.Template(
'<div id="panel-messages">',
'<div id="messages-tb"></div>',
'<div id="messages-area"><div id="messages-messages"></div></div>',
'</div>'
);

return {
_init: function(){
t.append(document.body);

tb = new Ext.Toolbar('messages-tb');
tb.add([ {text: 'Compose'} ]);

panel = new Ext.ContentPanel('panel-messages', {
toolbar: tb,
resizeEl: 'messages-messages',
autoScroll: true,
fitToFrame: true,
title: 'Messages',
closable: true
});

parentLayout = Freya.Gui.getLayout(); // returns an Ext.BorderLayout obj already in use
parentLayout.add('center', panel);

this.inited = true;
},
show: function(){
if(!this.inited){
this._init();
}
var p = parentLayout.getTabs().getTab('panel-messages');
p.show();
p.activate();
},
hide: function(){
var p = parentLayout.getTabs().getTab('panel-messages');
p.hide();
}
};
}();

tryanDLS
18 Apr 2007, 6:22 PM
Is p pointing to the right object - looks like it pointing to the layout, not the region? Also, I think you can just call activate - it calls show internally.

haibijon
18 Apr 2007, 6:37 PM
Got it, thanks. I was going about it a bit backwards, and you were right about p.

Had to change the last few lines to this...


panel = parentLayout.add('center', panel);

this.inited = true;
},
show: function(){
if(!this.inited){
this._init();
}
var p = parentLayout.getRegion('center');
p.showPanel(panel);
},
hide: function(){
var p = parentLayout.getRegion('center');
p.hidePanel(panel);
}