Permanent lists?

Feb 7, 2012 at 8:32 PM

Let me start by saying thanks for such a great tool :)

I am wondering if there is a way to create a permanent "list" source. To explain what I mean is could you set it up so that the page starts like this:

List 1 List 2
Item1
Item 2
Item 3
 

And you could end up with:

List 1 List 2
Item1
Item 2
Item 3
Item 1
Item 1
Item 1
Item 2
Item 2
Item 3

by dragging items from list 1 to list 2 multiple times? Sorry if I'm not being clear with my description.

Feb 7, 2012 at 9:39 PM
Edited Feb 7, 2012 at 9:40 PM

I've just found what I needed here - http://dragsort.codeplex.com/discussions/216174 - mcm_hams first post in that thread does exactly what I was looking to achieve.

Just in case anyone googles and wants to find it, the code I used was:

$("#list1, #list2").dragsort({ dragSelector: "div", dragBetween: true, dragEnd: saveOrder, placeHolderTemplate: "<li class='placeHolder'><div></div></li>" });

$("#list1 > li").each(function(i) { $(this).attr("list1", i); });
$("#list2 > li").attr("list2", true);

function saveOrder() {
	//restore lost item
	$("#list2 > li[list1]").each(function() {
		var idx = parseInt($(this).attr("list1"));
		if (idx >= $("#list1 > li").size())
			$("#list1").append($(this).clone());
		else
			$("#list1 > li:eq(" + idx + ")").before($(this).clone());
	});
	
	//remove extra item
	$("#list1 > li[list2]").remove();
	
	//reset order
	$("#list1 > li").each(function(i) { $(this).attr("list1", i); });
	$("#list2 > li").attr("list2", true);
}

With List 1 as the "source" list and "list 2" as the list to modify, it worked without even having to edit it - many thanks mcm_hams