Mulitple drag drop and select all

Aug 17, 2011 at 11:13 AM
Edited Aug 17, 2011 at 5:38 PM

Could it is possible that I select multiple boxes at one time and drop them in next list. I can click on a link or ctrl A to select all and drag & drop them. I am using "jQuery List DragSort" plugins.

Coordinator
Sep 30, 2011 at 9:23 AM
Edited Sep 30, 2011 at 9:26 AM

How about this code:

<style type="text/css">	
	body { -moz-user-select: none; -khtml-user-select: none; -webkit-user-select: none; user-select: none; }
</style>
function dragEnd() {
	$(".selected").removeClass("selected").not(this).show().insertAfter(this);
	dragging = false;
};

var ctrlDown = false, dragging = false;
$(window).keydown(function(ev) {
	if (ev.which == 17)
		ctrlDown = true;
	if (ev.which == 65 && ctrlDown)
		$("#list1 li").addClass("selected");
}).keyup(function(ev) {
	if (ev.which == 17) {
		ctrlDown = false;
		if (!dragging)
			$(".selected").removeClass("selected");
	}
});

$("#list1 li").mousedown(function() {
	if (!ctrlDown)
		return;
	$(this).addClass("selected");
	var hideSelected = function() {
		dragging = true;
		$(".selected").hide();
		$(this).unbind("mousemove", hideSelected);
		//dragsort stores the style of the draggeditem on the attribute data-origStyle in
order to restore on dragEnd, I'm using this to identify which item it is
$("[data-origstyle]").show(); }; $("#list1").mousemove(hideSelected).mouseup(function() { $(this).unbind("mousemove", hideSelected); }); });

With this code you hold down ctrl and select which boxes you want to drag (ctrl+a will select all, the css is to prevent all the text highlighting on the page when you do). When you drag an item all selected boxes apart from the one you are dragging is hidden, and when you drop the dragged item the selected items appear after the dragged item.