对 - 让它与 Fx.Sort 的实现兼容并保持它应有的排序等更棘手,这是一个工作示例,其中任何被单击的项目都会转到顶部然后展开:
http://jsfiddle.net/dimitar/FcN32/
具体到你:
Fx.Sort.implement({
adopt: function(el, pos) {
if (!this.element)
this.element = this.elements[0] && this.elements[0].getParent();
var len = this.currentOrder.length;
pos = (pos !== null && typeof pos === 'number')
? this.currentOrder.contains(pos) ? pos : len
: len;
this.elements.include(el);
if (pos === len) {
// don't care, attach to bottom.
el.inject(this.element);
this.currentOrder.push(this.elements.indexOf(el));
}
else {
// we are injecting at a particular place in the order
el.inject(this.elements[pos], "before");
var newOrder = this.currentOrder.slice(0, pos) || [];
newOrder.push(this.elements.indexOf(el));
this.currentOrder = newOrder.combine(this.currentOrder.slice(pos));
}
if (el.getStyle('position') == 'static') el.setStyle('position', 'relative');
this.rearrangeDOM();
}
});
这被称为instance.adopt(someel, <optional pos>)
其中 pos 是列表中的数字位置。如果省略,它将附加到尾部。希望能帮助到你...