开发者

jQueryUI Sortable won't accept connected Draggable on a nested UL

开发者 https://www.devze.com 2022-12-27 09:06 出处:网络
I\'ve posted an example here: http://jsfiddle.net/ericclemmons/LEHLX/2/ Really, what it comes down to is the classic \"assigning users to groups\" issue.I have a list of users and a list of groups, b

I've posted an example here: http://jsfiddle.net/ericclemmons/LEHLX/2/

Really, what it comes down to is the classic "assigning users to groups" issue. I have a list of users and a list of groups, but I'd like to be able to have nesting of the groups: user "Eric" would be in "Users", "Web", and "Administrators".

The problem is that I cannot开发者_开发问答 drag a user to an empty <ul> in the list.


I had to reformat your HTML a little bit and change the group ID to classes, try the updated demo.

HTML

<h3>Groups</h3>
<ul>
  <ul class="groups">
    <span>Administrators</span>
    <li></li>
  </ul>

  <ul class="groups">
    <span>Web</span>
    <li></li>
  </ul>
</ul>
<hr />
<h3>Users</h3>
<ul id="users">
    <li>Eric</li>
    <li>Richard</li>
    <li>Evan</li>
</ul>

Script

$('.groups').sortable({
    revert:      'invalid',
    placeholder: 'ui-state-highlight'
});

$('#users li').draggable({
    connectToSortable: '.groups',
    helper:            'clone'
});

I hope that is what you were trying to achieve.

Edit: Oh I forgot to add, I had to do this because it appears that sortable/draggable/droppable doesn't work on lists deeper than one level.

0

精彩评论

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