$.extend($.fn.layout.methods, {
remove: function(jq, region){
return jq.each(function(){
var panel = $(this).layout("panel",region);
if(panel){
panel.panel("destroy");
var panels = $.data(this, 'layout').panels;
panels[region] = $('>div[region=' + region + ']', $(this));
$.data(this, 'layout').panels = panels;
$(this).layout("resize");
}
});
},
add:function(jq, params){
return jq.each(function(){
var container =$(this);
var panel = $('>div[region=' + params.region + ']', container);
if(!panel.length){
var pp = $('<div/>').attr("region",params.region).addClass('layout-body').appendTo(container);
var cls = 'layout-panel layout-panel-' + params.region;
pp.panel($.extend({},params.options,{
cls : cls
}));
var panels = $.data(this, 'layout').panels;
panels[params.region] = pp;
$.data(this, 'layout').panels = panels;
$(this).layout("resize");
}
});
}
});
使用:
$('#layout').layout('remove','north');
$('#layout').layout('add',{
region:'north',
options:{
height:33
}
});