2012-04-15 84 views
3

我正在使用jQuery UI可排序。沒有窗口滾動我的可排序的項目工作,並留在遏制。 但是,如果我滾動窗口,我開始排序項目,我的項目首先移動到我的窗口滾動高度不再粘在我的鼠標指針! 我做錯了什麼?jQuery UI可排序窗口滾動

var purchased = []; 
$("#listitems").sortable({ 
    revert: true, 
    containment: '#drop', 
    stop: function(event, ui) { 
     purchased = []; 
     $("#listitems li").each(function() { 
      var elem = $(this); 
      var st = elem.attr('id'); 
      if (jQuery.inArray(st, purchased) == -1) { 
       purchased.push(st); 
      } 
     }); 
     console.log(purchased); 
    } 
}); 

    <div id="drop" class="clearfix" style="position:relative;margin:0 auto;min-height:160px;height:auto!important;height:160px;;margin-bottom:20px; border-top:1px solid #D4D4D4;border-bottom:1px solid #DADADA"> 
     <div style="position:absolute;top:-31px;left:10px; z-index:0"><h1 id="depose" style="font-size:2.6em; line-height:1em; color:#EBEBEB; font-weight:700; z-index:0">DRAG HERE</h1></div> 
     <ul id="listitems" style="position:relative;z-index:11" class="alt_content galerie-thumbs"> 
<li>image 1</li> 
<li>image 2</li> 
... 
     </ul> 
    </div> 

感謝您的幫助......

+0

你有沒有懷疑過這一點?我有完全相同的問題:( – 2013-04-19 16:00:32

+0

我也有這個問題,沒有解決方案,但我發現這個jQuery板上的討論與幾個可能的解決方案,可能有人工作:https://forum.jquery.com/topic/可排序偏移當元素被拖動和頁面滾動向下ff – igneosaur 2015-12-29 03:56:03

+0

另一個問題在這裏:http://stackoverflow.com/questions/2451528/jquery-ui-sortable-scroll-helper-element-膠印中的firefox-問題 – igneosaur 2015-12-29 04:07:19

回答

1

添加overflow: auto;到列表中的父/容器。