jquery ui sortable - 使用包含时拖动无法正常工作

问题描述 投票:4回答:1

我遇到了jquery ui sortable的问题,我无法拖动某些项目(因为项目元素的高度,我认为是基于的)

<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行是我尝试但没有工作的东西,但我想我可能只是略微偏离我如何使用它们。

javascript jquery jquery-ui jquery-ui-sortable sortables
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');
    },*/
});
© www.soinside.com 2019 - 2024. All rights reserved.