Skip to content

Instantly share code, notes, and snippets.

@jakearchibald
Created October 26, 2009 09:28
Show Gist options
  • Save jakearchibald/218534 to your computer and use it in GitHub Desktop.
Save jakearchibald/218534 to your computer and use it in GitHub Desktop.
var mySortable = new glow.widgets.Sortable('#mySortable', {
onSort : function () {
// this will contain the IDs of the items in the sortable, in order
var itemIds = [];
// get the children of the sortable containers - these are the items you drag
// Then sort them, and get the ID for each
mySortable.containers.children().sort().each(function () {
itemIds.push( this.id );
});
// send the order of the boxes back to the server
glow.dom.get('/saveorder.php?order=' + itemIds.join('|'), {
onLoad: function (response) {
// obviously you wouldn't really want to alert every time this worked
alert('Order sent to server');
},
onError: function (response) {
alert('Uh oh, something went wrong');
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment