4

我在无法拖动某些项目的地方遇到 jquery ui 可排序问题(我猜是因为项目元素的高度)

<div class="container">
<fieldset>
    <legend>handle 1 THIS CAN'T BE DRAGGED BELOW HANDLE 2</legend>
    <div>blah<br /></div>
</fieldset>
<fieldset>
    <legend>handle 2 BUT I CAN DRAG THIS ABOVE HANDLE 1</legend>
    <div style="display: none">blah<br /></div>
</fieldset>

$(".container").sortable({
   axis: 'y',
   handle: '> legend',
   containment: 'parent',
   /*cursorAt: {top: 1},
   start: function(event, ui) {
      ui.placeholder.height(ui.item.height());
      $(this).sortable('refreshPositions');
   },*/
});​

请参阅http://jsfiddle.net/ADyhR/10/ 编辑:它似乎在 jquery ui 1.8.9 中工作。它只是 1.8.18 中的一个错误吗?

注释掉的 javascript 行是我尝试过但没有奏效的东西,但我想我可能只是稍微偏离了我使用它们的方式。

4

1 回答 1

0

您可以使用该tolerance选项并将其值设置为tolerance: "pointer",。我已经更新了您的 DEMO 并创建了一个NEW DEMO

这是tolerance添加选项一起使用的 JS 代码:

$(".container").sortable({
    axis: 'y',
    tolerance: "pointer",
    handle: '> legend',
    containment: 'parent',
    /*cursorAt: {top: 1},
    start: function(event, ui) {
        ui.placeholder.height(ui.item.height());
        $(this).sortable('refreshPositions');
    },*/
});
于 2018-01-05T07:57:15.617 回答