jQuery UI: Only allow sortable within its own parent level, and not above or below

前端 未结 1 562
长情又很酷
长情又很酷 2021-01-05 02:54

Basically using a list structure, I\'m trying to make each li sortable within it\'s own level, but not within other levels. So if I\'m dragging down Number 1 it

相关标签:
1条回答
  • 2021-01-05 03:38

    Your HTML and selectors are both really screwed up. I've cleaned it up for you here. Note that you need to define different class names for the different levels of sortables, or at least make sure that they are not returned by the same selector. Check out this link for a fixed implementation: http://jsfiddle.net/GMUbj/

    You could also tune the selectors so you didn't have to continue defining class names and avoid this whole mess altogether, as in: http://jsfiddle.net/HWmz3/

    As noted in another answer you could also turn this on or off for individual sublists using the items option if you want to bother to apply a css class to all of the lists you want to sort (note that I left the class turned off on most of the items so you can see how it works): http://jsfiddle.net/DnaBs/

    0 讨论(0)
提交回复
热议问题