Guest User

Untitled

a guest
Nov 18th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. $(function() {
  2. $("#sortable").sortable({
  3. axis: 'y',
  4. update: function(event, ui) {
  5. var data = $(this).sortable('serialize');
  6. $.ajax({
  7. data: data,
  8. type: 'POST',
  9. url: 'updatesort.php'
  10. });
  11. }
  12. });
  13. });
  14.  
  15. <ul id="sortable" class="ui-sortable">
  16. <li id="item-1"><button class="removeli">remove</button></li>
  17. <li id="item-2"><button class="removeli">remove</button></li>
  18. <li id="item-3"><button class="removeli">remove</button></li>
  19. <li id="item-4"><button class="removeli">remove</button></li>
  20. <li id="item-5"><button class="removeli">remove</button></li>
  21. </ul>
  22.  
  23. $("#sortable button.removeli").on("click", function () {
  24. $(this).parent().remove();
  25. });
  26.  
  27. $(".removeli").click(function() {
  28. //
  29. // get <li>-id for removing it from the database
  30. //
  31.  
  32. $(this).closest("li").remove();
  33.  
  34. var data = $("#sortable").sortable('serialize');
  35. $.ajax({
  36. data: data,
  37. type: 'POST',
  38. url: 'updatesort.php'
  39. });
  40. });
Add Comment
Please, Sign In to add comment