Created
April 28, 2016 20:22
-
-
Save alexshagov/787f9505c56546252adee2898f7c208b to your computer and use it in GitHub Desktop.
blg.1-6
This file contains 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
$(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