My question is a duplicate of this question but the accepted answer contains a fiddle that is no more valid. So I need to ask it again.
I am using jquery Sortable to move elems from one list to another. On move I update the database accordingly but I need to move the elem back to its original position if the update on backend fails. How do I get this?
$(".connectedSortable").on("sortreceive", function (event, ui) {
//fetch the data to the API
if(data.status==200){
//fetch was successful
}else{
//fetch failed
//rollback to original position
}
});
I think the exact code I am looking for was in the fiddle but it doesn't work anymore... Note that I am skipping all the code that is not necessary to explain the issue