PDA

View Full Version : How to call BorderLayout-functions from external?



schoppet
9 Mar 2007, 12:55 AM
Hi,

I've created a BorderLayout similar to the ComplexLayout example:


CAI = function(){
var layout;
return {
init : function(){
layout = new Ext.BorderLayout('jrenmc6k', {
hideOnLayout: true,
north: {
split:false,
initialSize: 35,
titlebar: false
},
west: {
split:true,
initialSize: 200,
minSize: 175,
maxSize: 400,
titlebar: true,
collapsible: true,
animate: true
},
east: {
split:true,
initialSize: 202,
minSize: 175,
maxSize: 400,
titlebar: true,
collapsible: true,
animate: true
},
south: {
split:true,
initialSize: 100,
minSize: 100,
maxSize: 200,
titlebar: true,
collapsible: true,
animate: true
},
center: {
titlebar: true,
autoScroll:true,
closeOnTab: true
}
});
layout.beginUpdate();
layout.add(
'north',
new Ext.ContentPanel(
'toolbar',
{
title:'Toolbar',
}
)
);
layout.add(
'south',
new Ext.ContentPanel(
'statusbar',
{
title: 'Statusbar',
closable: false
}
)
);
layout.add(
'west',
new Ext.ContentPanel(
'navigationbar',
{
title: 'Navigationbar',
closable: false
}
)
);
layout.add(
'east',
new Ext.ContentPanel(
'informationbar',
{
title: 'Informationbar',
closable: false
}
)
);
layout.add(
'center',
new Ext.ContentPanel(
'editbar',
{
title: 'Editbar',
closable: false
}
)
);
layout.getRegion('west').hide();
layout.getRegion('east').hide();
layout.getRegion('south').hide();
layout.endUpdate();
},
toogleWest : function(){
var west = layout.getRegion('west');

if(west.isVisible()) {
west.hide();
} else {
est.show();
}

}
};
}();
Ext.EventManager.onDocumentReady(CAI.init, CAI, true);


This works.

But now I want to call the function "CAI.toggleWest();" from external, e.g. the FF-Firebug extension. But this doesn't work! e.g. I type in the console of Firebug "alert(CAI.layout);" and the popup only displays "[undefined]".

Is there any trick to get this to work?


Regards

Joerg

schoppet
9 Mar 2007, 3:08 AM
OK,

actually I managed it with defining a return-function:



CAI = function() {
var layout;
return {
layout : function(){
return layout;
}
}
};


So now I can make the following call "CAI.layout().getRegion('west').hide();"

Is there a simpler way to access the local variable "layout"?

schoppet
9 Mar 2007, 3:20 AM
OK,

sorry for this unnecessary thread.

I've got it to work by simple change definitions from "layout = ..." or "layout.get..." inside the init()-function to CAI.layout and now I can access the layout-property from external.