【发布时间】:2011-05-16 21:15:05
【问题描述】:
嘿,伙计们,我不能让一个功能正常工作,关键是要爬过父母,直到我得到一个触发切换动作的人。但是这个函数表现得很奇怪,当找到经过验证的标签时,它似乎没有返回 true 并完成递归方式。
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 */
$(document).ready(function(){
$("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
【问题讨论】:
标签: javascript javascript-framework