开发者

jQuery sortable is hard to use b/c it's easy to drag outside the lines - what should I do?

开发者 https://www.devze.com 2023-02-11 06:33 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消