2012-11-20 105 views
3

我有一些結構:jQuery的排序重新排序

li#lists 
--ul 
----li.category 

------ul.due 
--------li.item 

------ul.date 
--------li.item 

------ul.other 
--------li.item 
--------li.item 
--------li.item 

我需要SORD在ul.other元素我li.item元素。現在在某些類別中排序正在工作,但我需要將項目排序到另一個類別。

例如:我需要在「This is sortable 5」之後排序「This is sortable 2」。或在「This is sortable 2」之後排列「這是可排序的5」。

我的代碼(fiddle):

$('.category ul.other').sortable({ 
    items: "li", 
    helper: "clone", 
    cursor: "move", 
    placeholder: "drag-to", 
    opacity: 0.5, 
    connectWith: ".category ul.other" 
}).disableSelection(); 

回答

1

這是bug #4551。當擴展列表項被浮動時,connectWith選項顯然不能按預期方式工作。

從下面的規則中刪除float: left;在項目佈局的代價解決您的問題(你可能要指定一個固定寬度補償):

#lists .due li, 
#lists .date li, 
#lists .other li, 
#lists .title { 
    float: left; // <-- Remove this style. 
    padding: 8px; 
    margin-left: -9px; 
    border: 1px solid #fff; 
    border-radius: 2px; 
    margin-top: 1px; 
} 

你會發現一個更新的小提琴here