我想使用jquery draggable/droppable让用户选择一组对象(每个对象在角落都有一个复选框),然后将所有选定对象作为一个组拖动...
我无法弄清楚我的生活怎么做哈哈.
以下是我想要在每个可拖动对象上创建可用解决方案的内容,使用start()事件并以某种方式获取所有其他选定对象并将其添加到选择中
出于性能原因,我还在考虑让拖动的物体看起来像一组物体(它们是图像,所以可能是一堆照片).我认为如果你一次拖动几十个对象,使用可拖动功能可能会失败,这听起来更好吗?
这是我为一次拖动多个项目而编写的jQuery代码.它现在可以拖拽但不可挽回.
这是代码
$(document).on('click', function (e) {
var target = e.target;
if (!$(target).hasClass('a')) $('.selected').removeClass('selected');
});
$(document).delegate('.a', 'dblclick', function (e) {
$(this).addClass('selected');
});
$(document).delegate('.selected', 'mousedown', function (e) {
var div = $('<div></div>');
$('.selected').each(function () {
div.append($(this).clone());
});
div.prop('id', 'currentDrag');
$('#currentDrag').css({
left: e.pageX + "px",
top: e.pageY + "px"
});
$('body').append(div);
});
$(document).on('mouseup', function (e) {
var tgt = e.target;
var mPos = {
x: e.pageX,
y: e.pageY
};
$('.drop').each(function () {
var pos = $(this).offset(),
twt = $(this).width(),
tht = $(this).height();
}); …Run Code Online (Sandbox Code Playgroud) EDIT 3: Just to summarize what became quite a long question in the hope that someone might find it easier to get the gist of it and be able to help more easily:
What I want is to get the jsfiddle # 2 below (under EDIT 2) to work, in the sense that it should correctly drop multiple items in the right place, when selected and dragged.
Original question:
I'm trying to figure out how to make nestedSortable allow multiple …