In my previous post, I discussed how to add drag, drop, sort and delete functions to your website. However, it utilized the prototype and scriptaculous libraries. I had recently changed my site to only use the jQuery library so I needed a way to do this using jQuery. As with my previous post, I could not find any tutorials or how to’s on how to do this so I figured it out on my own and thought I’d share it with the rest of you.
If you are looking for a prototype and scriptaculous solution, look here: https://robertfrew.wordpress.com/2010/02/06/drag-drop-sort-delete-with-script-aculo-us/
Why would you need such a function? This is useful for things such as photo management. In my case, my users can manage their photo albums by viewing a thumbnail page. From that page, they can re-arrange the position of images by dragging them to the correct position. This utilizes the sortable function of jQueryUI. Upon dropping the thumbnail in it’s desired position, on the users screen, it sorts in the foreground. Behind the scenes, it updates the database and arranges the photos in order correctly. If they wish to delete an image, they can drag it to a trash can icon and drop it. It will then remove it from the thumbnail list, reorder (sort) the positions, and remove the image from the database.
Here is the code I used: