How to get the identifier of the sorted item?

I use Sort and get it and work. But I am trying to keep what is inside the lists.

Suppose I have 3 lists:

<ul id="top" class="connectedSortable"> <li>elem1</li> <li>elem2</li> <li>elem2</li> </ul> <ul id="left" class="connectedSortable"> </ul> <ul id="right" class="connectedSortable"> </ul> 

JQuery

 $("#top, #left, #right") .sortable({ connectWith: ".connectedSortable", stop: function(event, ui) { alert(this.id); // printing top, left right... } }) .disableSelection(); 

I tried using the stop event inside sortable, but it only returns the ul identifier. So I want jQuery to tell me when I moved elem1 from list1 to list2 (or any elemX , of course).

I am trying to make a homepage so that the user can independently determine the layout.

+7
source share
1 answer

I think you want to use receive callback:

http://jsfiddle.net/nzskv/1/

 $("#top, #left, #right").sortable({ connectWith: ".connectedSortable", receive: function(event, ui) { alert("[" + this.id + "] received [" + ui.item.html() + "] from [" + ui.sender.attr("id") + "]"); } }).disableSelection(); 
+16
source

All Articles