我必须将嵌套连接的可存储与jQuery UI一起使用。这意味着任何可排序对象都可以放在任何其他可排序对象中。但是,我受到jQuery UI中的此错误的影响:http://bugs.jqueryui.com/ticket/8180。简而言之,将可排序对象放在可排序对象之外会引发异常:"未捕获错误:HIERARCHY_REQUEST_ERR:DOM 异常 3"。
我有哪些选择?
虽然这个问题还没有得到解决,但您可以尝试在为 innermostContainer 分配值之前在可排序小部件的 _contactContainers() 中添加验证。
for (var i = this.containers.length - 1; i >= 0; i--){
// never consider a container that's located within the item itself
if($.contains(this.currentItem[0], this.containers[i].element[0]))
continue;
if(this._intersectsWith(this.containers[i].containerCache)) {
// if we've already found a container and it's more "inner" than this, then continue
if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0]))
continue;
if (this.currentItem[0] == this.containers[i].element[0]) {
continue;
}
innermostContainer = this.containers[i];
innermostIndex = i;
} else {
// container doesn't intersect. trigger "out" event if necessary
if(this.containers[i].containerCache.over) {
this.containers[i]._trigger("out", event, this._uiHash(this));
this.containers[i].containerCache.over = 0;
}
}
}
对于可以连接并放置在其他可排序对象内部的可排序对象,则 innermostContainer 被确定为当前选择的可排序对象。然后将占位符追加到其中。当 _clear() 在 mouseStop 上被调用,并且"this.placeholder.before(this.currentItem)"被调用时,currentItem入到自身之前。这会导致HIERARCHY_REQUEST_ERR:DOM 异常 3。
简单的检查,如果当前项是容器,则不允许将占位符追加到当前项。