A quick demo showing how to capture the order of connected sortable lists for a StackOverflow answer.
Created
October 24, 2013 17:10
-
-
Save anonymous/7141189 to your computer and use it in GitHub Desktop.
A Pen by Sinetheta.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul id="image-list1" class="sortable-list"> | |
<li id="a">A</li> | |
<li id="b">B</li> | |
<li id="c">C</li> | |
</ul> | |
<ul id="image-list2" class="sortable-list"> | |
<li id="1">1</li> | |
<li id="2">2</li> | |
<li id="3">3</li> | |
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.sortable-list').sortable({ | |
connectWith: '.sortable-list', | |
update: function(event, ui) { | |
var changedList = this.id; | |
var order = $(this).sortable('toArray'); | |
var positions = order.join(';'); | |
console.log({ | |
id: changedList, | |
positions: positions | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment