I needed a sortable list by drag & drop in jQuery Mobile running on my smartphone.
I did not want to reinvent the wheel, so I pick the code for public libraries to achieve a result that runs on Android 4 on my Nexus S with the Android browser.
Your feedback on other smartphones, on other browsers am interested. A small return on my twitter account (@ forresst17) will be appreciated. I would point your feedback on this post.
Tested and approved on:
Nexus S with Android 4.0 (my smartphone)
iPad2 with IOS 5.1 (Thanks Poulpator)
Toshiba AT200 with Android 4.0.3 (Thanks zboub_2000)
I also made several positive reports on desktop browsers:
Tip : If you not want to use the entire jQuery UI, you can get on the download page the jQuery UI components needed for our example:
Core
Widget
Mouse
Sortable
###3 - Add jQuery UI Touch Punch to work on touch devices
The sortable list works fine on a desktop browser. But if you want to do a test on your smartphone, it does not work.
There is a small plugin for jQuery UI to simulate touch events for drag & drop function on smartphones.
This tool is jQuery UI Touch Punch.
Please download the JS minified and save it in the same directory as your HTML file. Then add the JS in your HTML page.
The sortable list now works properly on your smartphone.
###4 - Conclusion
I hope it will serve you in your future developments. One must be aware that this is a trick and that this is not the best solution that exists.
The JS file from jQuery UI is pretty heavy, you can still reduce it by taking only the components listed above.
But I think, it’s the simplest pending another solution …