我使用this hack在UI 1.8.6中工作,但我似乎无法在1.8.17中使用它。
在可排序的接收方法中:
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
}
所以问题是,如何处理插入的项目?看来,在调用receive时,项目尚未插入(或创建)。是否对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 :(得分: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: 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: this.fromOutside ? this.currentItem : self.currentItem,
sender: inst ? inst.element : null
};
}
似乎已经完成了这个伎俩,但令人讨厌。并且可能不是万无一失的