0

我正在使用jQuery UI Draggable和Droppable。 当可拖动结束可拖拽时,可拖拽将滑落,这会将拖拽拉下并离开我的鼠标。jQuery UI Draggable位置不刷新?

请在这里看到的例子 http://jsfiddle.net/shane716/tB4L3/2/

我试图添加refreshPositions:真正到了可拖动,但它并没有解决问题。

HTML代码

<table> 
<tr class="droppable"><td>Drop to here</td></tr> 
<tr id="slidedown" style="display:none"> 
    <td> 
     <div> 
     A<br /> 
     A<br /> 
     A<br /> 
     A<br /> 
     A<br /> 
     </div> 
    </td> 
</tr> 
<tr><td class="draggable">Drag Me</td></tr> 

jQuery代码

$(".draggable").draggable({ 
    revert: "invalid", 
    cursor: "move", 
    opacity: 0.7, 
    refreshPositions: true, 
}); 

$(".droppable").droppable({ 
    greedy: true, 
    accept: ".draggable", 
    activeClass:"droppable-active", 
    tolerance: "pointer", 
    over: function(event, ui) { 
    $("#slidedown").slideDown({duration:2000}); 
} 

});

带'助手'的事件,'助手'不会回复到可拖动的位置。 http://jsfiddle.net/shane716/tB4L3/3/

我的问题是如何保持可拖动的位置相同,我的鼠标的

+0

当IM给你的“拖箱” DIV一个'位置:绝对'它对我来说工作得很好 –

回答

2

你可以使用一个帮手:http://jsfiddle.net/tB4L3/4/

$(".draggable").draggable({ 
    revert: "invalid", 
    cursor: "move", 
    opacity: 0.7, 
    helper: function() { 
     return $(this).clone().appendTo('body'); 
    }, 
    start: function() { 
     $(this).hide(); 
    }, 
    stop: function() { 
     $(this).show(); 
    } 
});