我的要求参考了jQuery UI Layout中提到的demo
如上所示,我需要获得 3 个切换器,但我的集成没有向我显示三个彩色切换器按钮。我检查了演示页面和我的网站上内容的加载,但 div itseld 没有填充到我的 html 中...... :(
我错过了什么吗?
我做了以下事情:
$(document).ready(function(){
// CREATE THE LAYOUT
myLayout = $('body').layout({
resizeWhileDragging: true
, fxName: "none"
, west__size: westDefaultSize
, south__size: southDefaultSize
, spacing_open: 8
, spacing_closed: 8
, north__spacing_open: 0
, west__togglerLength_closed: 105
, west__togglerLength_open: 105
, south__togglerLength_closed: 105
, south__togglerLength_open: 105
, west__togglerContent_closed: toggleButtons
, west__togglerContent_open: toggleButtons
, south__togglerContent_closed: toggleButtons
, south__togglerContent_open: toggleButtons
});
// SET OBJECT POINTERS FOR CONVENIENCE
var
$westToggler = myLayout.togglers.west
, $southToggler = myLayout.togglers.south
;
var toggleButtons = '<div class="btnToggler"></div>'
+ '<div class="btnReset"></div>'
+ '<div class="btnExpand"></div>';
// UN-BIND DEFAULT TOGGLER FUNCTIONALITY
$westToggler.unbind("click");
$southToggler.unbind("click");
// BIND CUSTOM WEST METHODS
$westToggler.find(".btnToggler") .click( toggleWest );
$westToggler.find(".btnExpand") .click( expandWest );
$westToggler.find(".btnReset") .click( resetWest );
// BIND CUSTOM SOUTH METHODS
$southToggler.find(".btnToggler") .click( toggleSouth );
$southToggler.find(".btnExpand") .click( expandSouth );
$southToggler.find(".btnReset") .click( resetSouth );
// ADD TOOLTIPS TO CUSTOM BUTTONS
$(".btnExpand").attr("title", "Expand to full size");
$(".btnReset") .attr("title", "Reset size to default");
});
// CUSTOM WEST METHODS
function toggleWest (evt) { myLayout.toggle("west"); evt.stopPropagation(); };
function expandWest (evt) { sizePane("west", 500); };
function resetWest (evt) { sizePane("west", westDefaultSize); };
// CUSTOM SOUTH METHODS
function toggleSouth (evt) { myLayout.toggle("south"); evt.stopPropagation(); };
function expandSouth (evt) { sizePane("south", 9999); }; // ie, make as big as possible
function resetSouth (evt) { sizePane("south", southDefaultSize); };
// GENERIC HELPER FUNCTION
function sizePane (pane, size) {
myLayout.sizePane(pane, size);
myLayout.open(pane); // open pane if not already
};
只有一个区别:
var myLayout = $('#layout-wrapper').layout();
我在页面加载时调用布局,然后在按钮单击时添加切换器:
myLayout.addToggleBtn();
类似上面的东西。
请让我知道当为布局完成实例化时,我们如何使用切换器实现布局。