ソート可能なリストでアイテムの正確な数を維持する必要があり、それを行うのに苦労しています。増分をカウントするリスト #1 からドラッグを開始した瞬間、それ以降は余分なアイテムがプレイされています。リスト #2 にカーソルを合わせると、カウントが増えます。
$(function () {
$("#ul1, #ul2").sortable({
connectWith: ".connectedSortable"
}).disableSelection();
});
function update_counts() {
var n_ul1 = $("#ul1 li").length;
var n_ul2 = $("#ul2 li").length;
$("#count1").html(n_ul1);
$("#count2").html(n_ul2);
}
$(function () {
$("#ul2,#ul1").droppable({
over: function (ev, ui) {
update_counts();
},
drop: function (ev, ui) {
update_counts();
}
}).disableSelection();
});