Created
December 31, 2017 06:11
-
-
Save jindrichsirucek/1ce188b8cf6f94471fe438a32f3c1a90 to your computer and use it in GitHub Desktop.
jqeury Api sortable needed
This file contains hidden or 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() {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