jQuery UI sortable connected list item snaps to second last position

霸气de小男生 提交于 2019-12-13 02:38:12

问题


I have two sortable lists next to each other.

See this example: http://jsfiddle.net/2Fbt6/

If you drag "Item 6" to the right, it gets added to the second last position instead to the last. If you drag "Item 6" to the right, to the left, and again to the right, it's correct.

Code:

HTML:

<div class="categories">
<ul class="items">
  <li id="item1" class="item ui-state-default">Item 1</li>
  <li id="item2" class="item ui-state-default">Item 2</li>
  <li id="item3" class="item ui-state-default">Item 3</li>
  <li id="item4" class="item ui-state-default">Item 4</li>
  <li id="item5" class="item ui-state-default">Item 5</li>
  <li id="item6" class="item ui-state-default">Item 6</li>
</ul>

<ul class="items" style="background: #efefef;">
  <li id="item5" class="item ui-state-default">Item 1</li>
  <li id="item6" class="item ui-state-default">Item 2</li>
  <li id="item7" class="item ui-state-default">Item 3</li>
</ul>
</div>

CSS:

.items { width: 100px; float: left; height: 500px;list-style-type: none;}
.placeholder { height: 18px; background-color: #ffd;}

JS:

$( ".items" ).sortable({
    connectWith: ".items",
    placeholder: 'placeholder'
});
$( ".categories" ).sortable({
    connectWith: ".categories"
});

I'd be pleased if anybody could think of a workaround for this issue. In my case, the left list may be very long, and it's annoying, if a user has to scroll up all the way, to drag the element to the last position of the right list.

EDIT:

Seems like this is a bug in jQuery-ui that will be addressed in version 1.11: http://bugs.jqueryui.com/ticket/9314


回答1:


Seems like this is a bug in jQuery-ui that will be addressed in version 1.11: http://bugs.jqueryui.com/ticket/9314



来源:https://stackoverflow.com/questions/21233381/jquery-ui-sortable-connected-list-item-snaps-to-second-last-position

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!