Skip to content

Instantly share code, notes, and snippets.

@jindrichsirucek
Created December 31, 2017 06:11
Show Gist options
  • Save jindrichsirucek/1ce188b8cf6f94471fe438a32f3c1a90 to your computer and use it in GitHub Desktop.
Save jindrichsirucek/1ce188b8cf6f94471fe438a32f3c1a90 to your computer and use it in GitHub Desktop.
jqeury Api sortable needed
$(function() {jQuery( "#sortable" ).sortable({
update: function( event, ui ) {onOrderChange(event, ui)}
});
function onOrderChange(event, ui)
{
jQuery.ajax({ url: 'https://77prani.cz/posun_prani.php?pozice='+ui.item.index()+'&id='+ui.item.attr("id"),
data: {action: 'test'},
type: 'post',
success: function(output) {
//Succesfully saved
//alert("Saved!");
jQuery( "#sortable li" ).each(function(index){
$(this).children('span').html(index+1+"."); });
},
error: function (xhr, ajaxOptions, thrownError) {
//Error during saving
//alert(xhr.status);
//alert(thrownError);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment