2012-03-24 41 views
0

我正在本地开发页面,所以很遗憾我无法展示一个示例,但我有两个“列表”构建的jQuery手机。jQuery:可排序的嵌套但不连续

我希望这两个列表可以使用jquery ui插件进行排序。

它可能是这个样子:

<div class="sortable"> //1st sortable wrapper 
    <div> //list item for 1st sortable wrapper 
    <div> 
    <div> 
     <div class="sortable"> //2nd sortable list wrapper 
     <div> //list item for 2nd sortable wrapper 

然后我打电话

jQuery(".sortable").sortable() 

所以我基本上有两个独立的sortables。第一组可排序内的一组可排序项。每个分组应独立于另一组可排序项。

第二组可排序项动态添加到页面可能没有任何价值。

加入后,我打电话

jQuery(".sortable").sortable('refresh') 

无果,动态添加第二套sortables是从来没有排序。当我尝试并拖动它们时,父级.sortable反而会拖动。

我看到的所有插件都假设元素紧接着下一个元素。

对此有何看法?

回答

0

在jQuery-ui-sortable文件开发版本中。

还有就是占该行:

变化:

if(itemElement != this.currentItem[0] //cannot intersect with itself 
      && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before 
      && !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked 
      && (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true) 
      //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container 
     ) 

到:

if(itemElement != this.currentItem[0] //cannot intersect with itself 
      && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before 
      && !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked 
      && (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true) 
      && itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container 
     ) 

Bascially,除去在最后一行的注释。