Skip to content

Instantly share code, notes, and snippets.

@alexshagov
Created April 28, 2016 20:22
Show Gist options
  • Save alexshagov/787f9505c56546252adee2898f7c208b to your computer and use it in GitHub Desktop.
Save alexshagov/787f9505c56546252adee2898f7c208b to your computer and use it in GitHub Desktop.
blg.1-6
$(function(){
var updated_order = function(){
var data_arr = [];
$.each($(".picture"), function(index){
$(this).attr("priority", index);
data_arr.push({id: $(this).attr("data-id"), priority: index })
});
return data_arr;
}
$(".container").sortable({
cursor: "move",
stop: function(event, ui){
var data = updated_order();
$.ajax({
url: "pictures/sort",
type: "PUT",
data: {"data": JSON.stringify(data)},
success: function(msg){
console.log("Sorted!");
}
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment