I’m using jqueries UI sortable plugin with 2 connected lists. I’m trying to get sortable to add a certain class to the li when it is dropped into certain uls. So depending on the ul it goes to, I want it to remove the old class and add a new different class which will be ul dependent. For example: I have a complete list and a archived list. I want it to change classes when moving from completed to archive and vice versa. I did some research and found:
receive: function(event, ui) { //Element ready to be dropped to new place
source_element = $(ui.item); // here is your selected item
}
Which I think gives me the item just moved, but I’m not sure how to make it know which ul its in now, and which it came from. Any help would be great, thanks!
The code listed below should do what you want. I borrowed the HTML layout from the jquery site and then added in the functions you needed. There are several steps involved to make it work.
connectWithoption.sortreceive()which only fires when a li is moved from one column to the other. I set a variable so that I can tell when thesortstop()fires whether I’m in a new column or not.