2012-01-18 75 views
0

我曾在UI 1.8.6中使用this hack,但我似乎无法让它在1.8.17中工作。jQuery UI排序 - 获取丢弃项目的句柄

  • 我想将列表中的项目拖动到可排序的列表中。
  • 该项目应下探后继续留在源列表中(这样他们就可以被添加n次)
  • 当我把项目进入排序,我想要得到的掉落物品的实例的句柄在排序。

在排序的方法获得:

receive: function(e, ui){ 
    // ui.item is the original dragged item, not the clone that gets created when dropped 
    // ui.helper is a separate clone of the dragged item, it does not get inserted into the sortable 
} 

所以,问题是,我怎么插入的项目的句柄?看起来该项目在接收被调用之前还没有被插入(或创建)。是否对jQuery UI进行了更改,或者我错过了什么?

这里是我的代码:

$('form').sortable({ 
    placeholder: "placeholder", 
    forcePlaceholderSize: true, 
    receive: function (ev, ui) { 
     // need handle on dropped item here. ui.item and ui.helper are not it 
    } 
}); 


$('.draggableTings').draggable({ 
    helper: "clone" 
    , appendTo: "body" 
    , revert: "invalid" 
    , connectToSortable: "form" 
}); 

感谢

回答

0

与此

_uiHash: function(inst) { 
    var self = inst || this; 
    return { 
     helper: self.helper, 
     placeholder: self.placeholder || $([]), 
     position: self.position, 
     originalPosition: self.originalPosition, 
     offset: self.positionAbs, 
     item: this.fromOutside ? this.currentItem : self.currentItem, 
     sender: inst ? inst.element : null 
    }; 
} 

更换此

_uiHash: function(inst) { 
    var self = inst || this; 
    return { 
     helper: self.helper, 
     placeholder: self.placeholder || $([]), 
     position: self.position, 
     originalPosition: self.originalPosition, 
     offset: self.positionAbs, 
     item: self.currentItem, 
     sender: inst ? inst.element : null 
    }; 
} 

似乎做的伎俩,虽然讨厌。并可能不是傻瓜

相关问题