how make draggable li element with jquerymobile?

2020-02-26 03:50发布

问题:

I am new in web mobile.

When i want to make draggable item in we i just use jquery ui, what is the way to do it in mobile web application?(i am using jquerymobile) Should we use jquery ui for that also in web mobile or exist other good way?

Thanks,

回答1:

jQuery mobile has no built in support for creating draggables. Bringing in jQuery UI to create draggables will work fine providing you bring in something to make touch events work (jQuery UI doesn't support touch events currently). jQuery UI Touch Punch is a good choice to provide such functionality.

A custom build of jQuery UI that only includes the draggable plugin and its dependencies is only 4 K minified. jQuery UI Touch Punch is 1/2 K. By comparison jQuery itself is 32 K. jQuery UI's draggable is quite robust so I think it's worth it.

There's some relevant discussion and a more lightweight solution in this answer as well - Javascript Drag and drop for touch devices.