以下の最小限の作業例では、ボックス '1'をドラッグして '2'ボックスにドロップすると2つのボックスを交換します。問題は、ボックス '1'をドロップすると、そのスタイルの '上部'が&の '左'の値になって、ドロップする場所から離れた位置に配置されるということです。そのクラスには 'ui-draggable-dragging'が含まれています。上部の&の左の値は、要素がドロップ前にドラッグされた量に関連しているようです。ドラッグは「中断」され、それゆえ、残った「ユー・ドラッガブル・ドラッグ」クラスでしたか?2つのjQueryドラッグ可能なリスト項目が正しく動作しない(jsFiddleの例で)
スワップをシームレスに機能させるには、何が欠けていますか? full jsfiddle example here
<html>
<head>
<script type="text/javascript" src="includes/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="includes/jquery-ui-1.8.2.custom.min.js"></script>
<script type="text/javascript">
jQuery.fn.swapWith = function(to) {
return this.each(function() {
var copy_to = $(to).clone(true);
var copy_from = $(this).clone(true);
$(to).replaceWith(copy_from);
$(this).replaceWith(copy_to);
});
};
$(document).ready(function() {
options = {revert: true};
$("li").draggable(options)
$('#wrapper').droppable({
drop: function(event, ui) {
$(ui.draggable).swapWith($('#two'));
}
});
});
</script>
</head>
<body>
<form>
<ul id="wrapper">
<li id='one'>
<div style="width: 100px; height: 100px; border: 1px solid green">
one<br /></div>
</li>
<li id='two'>
<div style="width: 110px; height: 110px; border: 1px solid red">
two<br /></div>
</li>
</ul>
<br />
</form>
</body>
</html>