【发布时间】:2011-03-05 13:21:50
【问题描述】:
我正在使用带有多个连接列表的 jquery ui 的可排序功能。这些列表包含在可拖动、可调整大小的 div 中,并在 div 上带有“溢出:自动”。当我将一个带有很多列表项(‹li›)的 div 放在另一个 div 上方时,我遇到了问题。
顶部 div 包含许多 li 元素,这意味着它实际上延伸到比实际显示的要低得多的位置。这意味着当我移动底部 div 中的一个元素时,该元素将在顶部 div 的可排序列表(这不应该发生,因为它是隐藏的)和底部 div 的可排序列表之间跳转,使其在两者之间闪烁。
这是一个主要问题,因为用户很难将 li 放在正确的 div 中,如果这是他/她放置 div 的方式。
我想要的是 li 只连接到它当前悬停的 div 的列表。
有人知道如何解决这个问题吗?
技术细节
以底部div为例:
<div style="height: 310px; width: 200px; z-index: 14; left: 909px; top: 215px; position: absolute;" class="Category ui-draggable ui-resizable p-resize-snap" id="cat883">
<input type="hidden" value="310" id="hiddenHeight883" name="ctl00$MainContentPlaceHolder$hiddenHeight883"><div style="height: 20px;" class="CategoryHeader">
<table style="table-layout: fixed;">
<tbody><tr>
<td style="width: 16px;"><a onclick="return ToggleLinks("883");" href="#">^</a></td><td class="categoryNameTD"><span class="categoryName">Games </span><span style="display: none;"><input type="checkbox" name="ctl00$MainContentPlaceHolder$cbxCat883" id="cbxCat883"></span></td><td style="width: 16px;"><a onclick="return Edit();" href="#">E</a></td>
</tr>
</tbody></table>
</div><div style="height: 274px; overflow: auto; border-bottom: 1px dotted rgb(221, 221, 221);" id="catLinks883">
<div class="CategoryLinks">
<ul style="list-style-type: none; margin: 0px; padding: 0px;" class="drpList ui-sortable"><li style=""><div class="drpLink">
<table style="width: 100%; table-layout: fixed;">
<tbody><tr>
<td style="width: 16px;"><img style="height: 16px; width: 16px;" alt="@" src="http://www.youtube.com/favicon.ico"></td><td style="overflow: hidden; white-space: nowrap;"><a target="_blank" href="http://www.youtube.com/" title="Youtube">Youtube</a></td><td style="width: 16px;"><span style="display: none;"><input type="checkbox" name="ctl00$MainContentPlaceHolder$cbx722" id="cbx722"></span></td>
</tr>
</tbody></table>
</div></li><li style=""><div class="drpLink">
<table style="width: 100%; table-layout: fixed;">
<tbody><tr>
<td style="width: 16px;"><img style="height: 16px; width: 16px;" alt="@" src="http://www.metacritic.com/favicon.ico"></td><td style="overflow: hidden; white-space: nowrap;"><a target="_blank" href="http://www.metacritic.com/" title="Metacritic - Movie Reviews, TV Reviews, Game Re...">Metacritic - Movie Reviews, TV Reviews, Game Re...</a></td><td style="width: 16px;"><span style="display: none;"><input type="checkbox" name="ctl00$MainContentPlaceHolder$cbx710" id="cbx710"></span></td>
</tr>
</tbody></table>
</div></li><li style="display: list-item;"><div class="drpLink">
<table style="width: 100%; table-layout: fixed;">
<tbody><tr>
<td style="width: 16px;"><img style="height: 16px; width: 16px;" alt="@" src="http://www.myspace.com/favicon.ico"></td><td style="overflow: hidden; white-space: nowrap;"><a target="_blank" href="http://www.myspace.com/" title="MySpace">MySpace</a></td><td style="width: 16px;"><span style="display: none;"><input type="checkbox" name="ctl00$MainContentPlaceHolder$cbx725" id="cbx725"></span></td>
</tr>
</tbody></table>
</div></li><li style=""><div class="drpLink">
<table style="width: 100%; table-layout: fixed;">
<tbody><tr>
<td style="width: 16px;"><img style="height: 16px; width: 16px;" alt="@" src="http://www.fz.se/favicon.ico"></td><td style="overflow: hidden; white-space: nowrap;"><a target="_blank" href="http://www.fz.se/" title="FZ">FZ</a></td><td style="width: 16px;"><span style="display: none;"><input type="checkbox" name="ctl00$MainContentPlaceHolder$cbx707" id="cbx707"></span></td>
</tr>
</tbody></table>
</div></li><li style=""><div class="drpLink">
<table style="width: 100%; table-layout: fixed;">
<tbody><tr>
<td style="width: 16px;"><img style="height: 16px; width: 16px;" alt="@" src="http://n4g.com/favicon.ico"></td><td style="overflow: hidden; white-space: nowrap;"><a target="_blank" href="http://n4g.com/" title="N4G.com : All the latest game news">N4G.com : All the latest game news</a></td><td style="width: 16px;"><span style="display: none;"><input type="checkbox" name="ctl00$MainContentPlaceHolder$cbx708" id="cbx708"></span></td>
</tr>
</tbody></table>
</div></li><li style=""><div class="drpLink">
<table style="width: 100%; table-layout: fixed;">
<tbody><tr>
<td style="width: 16px;"><img style="height: 16px; width: 16px;" alt="@" src="http://www.facebook.com/favicon.ico"></td><td style="overflow: hidden; white-space: nowrap;"><a target="_blank" href="http://www.facebook.com/" title="Facebook">Facebook</a></td><td style="width: 16px;"><span style="display: none;"><input type="checkbox" name="ctl00$MainContentPlaceHolder$cbx724" id="cbx724"></span></td>
</tr>
</tbody></table>
</div></li><li style=""><div class="drpLink">
<table style="width: 100%; table-layout: fixed;">
<tbody><tr>
<td style="width: 16px;"><img style="height: 16px; width: 16px;" alt="@" src="http://www.quakelive.com/favicon.ico"></td><td style="overflow: hidden; white-space: nowrap;"><a target="_blank" href="http://www.quakelive.com/" title="QUAKE LIVE">QUAKE LIVE</a></td><td style="width: 16px;"><span style="display: none;"><input type="checkbox" name="ctl00$MainContentPlaceHolder$cbx713" id="cbx713"></span></td>
</tr>
</tbody></table>
</div></li><li style=""><div class="drpLink">
<table style="width: 100%; table-layout: fixed;">
<tbody><tr>
<td style="width: 16px;"><img style="height: 16px; width: 16px;" alt="@" src="http://lifehacker.com/favicon.ico"></td><td style="overflow: hidden; white-space: nowrap;"><a target="_blank" href="http://lifehacker.com/" title="Lifehacker, tips and downloads for getting thin...">Lifehacker, tips and downloads for getting thin...</a></td><td style="width: 16px;"><span style="display: none;"><input type="checkbox" name="ctl00$MainContentPlaceHolder$cbx721" id="cbx721"></span></td>
</tr>
</tbody></table>
</div></li><li style=""><div class="drpLink">
<table style="width: 100%; table-layout: fixed;">
<tbody><tr>
<td style="width: 16px;"><img style="height: 16px; width: 16px;" alt="@" src="http://quicksilverscreen.com/favicon.ico"></td><td style="overflow: hidden; white-space: nowrap;"><a target="_blank" href="http://quicksilverscreen.com/" title="http://quicksilverscreen.com/">http://quicksilverscreen.com/</a></td><td style="width: 16px;"><span style="display: none;"><input type="checkbox" name="ctl00$MainContentPlaceHolder$cbx723" id="cbx723"></span></td>
</tr>
</tbody></table>
</div></li></ul>
</div>
</div>
<div class="ui-resizable-handle ui-resizable-e"></div><div class="ui-resizable-handle ui-resizable-s"></div><div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se" style="z-index: 1001;"></div></div>
更新:
初始化:我已经尝试过使用 helper: 'clone', appendTo: "几个不同的元素,包括 body" 和 zIndex: 10000 但它们都没有帮助我。
我希望 appendTo 属性实现的是使 li 在我的“.Category”(的视觉部分)内可放置,即包含列表的 div。
$(".drpList").sortable({ handle: ".drpLink img", connectWith: ".drpList", tolerance: "pointer" });
【问题讨论】:
-
您能否将您的可排序列表初始化包括在内?
-
@Jeremy Battle:我更新了帖子!
-
@peterthegreat 您的 html 有很多额外的复杂性,超出了可能的必要性。看看这里:jsfiddle.net/LpeLz,让我知道这是否是您正在寻找的行为。 (抱歉只使用了 2 个不同的图标,我不想复制一堆列表项......)
-
@Jeremy Battle:额外的东西有很多不同的原因(比图片上看起来更复杂),但你的例子和我的一样有闪烁的问题。我在 Firefox 3.6 顺便说一句。
-
@peterthegreat 抱歉,我误解了这个问题。那真是令人难以置信……我玩了一段时间,它真的不想正常工作。