我正在使用 jquery draggable 我当前的项目,例如,我有一个关于 jquery draggable 的问题;我从列表中拖放一个项目 b 列表,但此时出现问题。如果我的列表很长,y 轴会变得混乱。可拖动的项目出现在光标下方。
$(function () {
$( "#list1 li" ).draggable({
cursor: "move",
appendTo: "body",
helper: "clone"
});
$( "#list3" ).droppable({
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
accept: ":not(.ui-sortable-helper)",
drop: function( event, ui ) {
$( "<li></li>" ).text( ui.draggable.text() ).appendTo( this );
ui.draggable.remove();
$.ajax({
url: "@Url.Action("AddTag", "Home")",
type: "POST",
dataType: "json",
data: { tagId: ui.draggable.attr("data"),Id:@ViewContext.RouteData.Values["id"] },
success: function (data) {
},
error: function () {
}
});
},
});
$( "#list3 li" ).draggable({
cursor: "move",
appendTo: "body",
helper: "clone",
stop:function(event,ui){
$(this).remove();
$.ajax({
url: "@Url.Action("DeleteTag", "Home")",
type: "POST",
dataType: "json",
data: { tagId: $(this).attr("data"),Id:@ViewContext.RouteData.Values["id"] },
success: function (data) {
},
error: function () {
}
});
}
});
});