Reputation: 367
I am using following code for make my divs sortable
$('.outersortable').sortable({
handle: ".drag",
cursor: "e-size",
placeholder: "ui-state-highlight",
axis: "y" });
I want to run ajax call and save changes (order of div) and also it just make divs dragable but not replace divs
Upvotes: 0
Views: 4694
Reputation: 1155
You should use sortable update
event whitch is fired when user stopped sorting and the DOM position has changed.
You grab current elements order with $('.outersortable').sortable("toArray");
and use jQuery ajax
function to send it to backend.
Full example:
$('.surEdOuterSortable').sortable({
handle: ".spritesHandlerIcon",
cursor: "e-size",
placeholder: "ui-state-highlight",
axis: "y"
update: function(event, ui) {
order = $('.outersortable').sortable("toArray");
$.ajax({
url: 'controller/action',
data: {order:order},
});
}
});
Upvotes: 1