我的要求是指jQuery UI Layout
中提到的演示我需要如上所示获得3个交换器,但我的集成并未向我显示三个彩色切换按钮。我在demo和我的网站上的页面上检查了内容的加载,但是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();
如上所述。
请告诉我如何在布局实例化时使用切换器实现布局。
答案 0 :(得分:3)
首先我可以看到你缺少toggleButtons
定义。在您发布的示例中
toggleButtons = '<div class="btnToggler"></div>'
+ '<div class="btnReset"></div>'
+ '<div class="btnExpand"></div>';
但是我没有在你的代码中看到它们,但是你在布局定义中引用了它们?