Posted By

eternicode on 04/28/10


Tagged

javascript jquery ui sortable


Versions (?)

jQuery UI: Get sortables position before/after and change.


 / Published in: JavaScript
 

  1. /*
  2. <div id="rleft">
  3.   <p>etc</p>
  4.   <p>etc</p>
  5.   <p>etc</p>
  6. </div>
  7. */
  8.  
  9. $("#rleft").sortable({
  10. axis: 'y',
  11. items: "p",
  12. start: startdrag,
  13. stop: stopdrag,
  14. })
  15.  
  16. function startdrag(event, ui){
  17. var old_position = $("#rleft p").index(ui.item)
  18. ui.item.data("old", old_position)
  19. }
  20. function stopdrag(event, ui){
  21. var new_position = $("#rleft p").index(ui.item)
  22. ui.item.data("new", new_position)
  23. var old_position = ui.item.data("old")
  24. var change = new_position - old_position
  25. var moved_up = change > 0
  26. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: KenCorbettJr on January 5, 2011

Awesome!!! This is just what I needed. Thanks!

You need to login to post a comment.