unction dock(e){
if(e.get(0).tagName != "BODY"){
alert("current : "+e.get(0).tagName)
e.siblings(".splitter-bar").each(function(){
alert("found sibling : "+$(this).get(0).tagName)
if($(this).length > 0){
e.parent().trigger('toggleDock')
alert("triggered parent : "+e.parent().get(0).tagName)
return true
}
})
if ( dock(e.parent()) ){
alert("validated parent : "+e.parent().get(0).tagName)
return true
}
alert("end dock(), current : "+e.get(0).tagName)
}
return false
}
$(".dockme").live('click', function(event) {
a = dock($(this))
alert("dock returned :"+a)
});
整个代码:
/* when the page is loaded */
(文档)$。就绪(函数(){
$("body").splitter({
splitVertical: true,
outline: true,
sizeLeft: 30, minLeft: 0, maxLeft: 100,
resizeToWidth: true,
anchorToWindow: true,
dock: "left",
dockSpeed: 200,
cookie: "docksplitter"
});
$("#a").splitter({
splitHorizontal: true,
outline: true,
sizeBottom: 30, minBottom: 0, maxBottom: 30,
dock: "bottom",
dockSpeed: 200,
cookie: "docksplitter"
});
$("#b").splitter({
splitVertical: true,
sizeRight: 320, minRight: 0, maxRight: 320,
dock: "right",
dockSpeed: 200,
cookie: "docksplitter"
});
function dock(e){
if(e.get(0).tagName != "BODY"){
alert("current : "+e.get(0).tagName)
e.siblings(".splitter-bar").each(function(){
alert("found sibling : "+$(this).get(0).tagName)
if($(this).length > 0){
e.parent().trigger('toggleDock')
alert("triggered parent : "+e.parent().get(0).tagName)
return true
}
})
if ( dock(e.parent()) ){
alert("validated parent : "+e.parent().get(0).tagName)
return true
}
alert("end dock(), current : "+e.get(0).tagName)
}
return false
}
$(".dockme").live('click', function(event) {
a = dock($(this))
alert("dock returned :"+a)
});
}); html:http://pastie.org/1329885
答案 0 :(得分:0)
e.siblings(...).each
内的功能未从true
返回dock
。
所以而不是
e.siblings(".splitter-bar").each(function(){
alert("found sibling : "+$(this).get(0).tagName)
if($(this).length > 0){
e.parent().trigger('toggleDock')
alert("triggered parent : "+e.parent().get(0).tagName)
return true
}
})
我认为你需要说:
var triggeredInSplitterBar = false; // ADDED
e.siblings(".splitter-bar").each(function(){
alert("found sibling : "+$(this).get(0).tagName);
if($(this).length > 0){
e.parent().trigger('toggleDock');
alert("triggered parent : "+e.parent().get(0).tagName);
triggeredInSplitterBar = true; // CHANGED
}
});
if (triggeredInSplitterBar) { return true; } // ADDED