jQuery sortable is hard to use b/c it's easy to drag outside the lines - what should I do?
I'm using the jQuery ui's sortable feature:
http://jqueryui.com/demos/sortable/
Works great as long as the user never drags the handle past the left border of the containing , but in practice this is easy开发者_StackOverflow社区 to do - and even easier on my website, where the sortable handles have a little less whitespace to the left...
Ideas? Thanks!
I think you're looking for the containment
option:
Constrains dragging to within the bounds of the specified element - can be a DOM element, 'parent', 'document', 'window', or a jQuery selector.
Here's a demo: http://jsfiddle.net/andrewwhitaker/ZB5Tm/1/
Notice what happens when you remove the containment
option.
精彩评论