我在頁面上有一個jQueryUI可拖動對象和一個可排序對象。將Draggable連接到Sortable會導致幫助器元素跳轉
將元素從可拖動元素拖到可排序元素會導致拖動元素跳轉到頁面左上角。
這裏的演示:http://jsfiddle.net/travisrussi/aBhDu/1/
重現:
- 將 '項目5' 從可拖動DIV(機頂盒)的排序DIV(底盒)
實際結果:
- 第5項跳到左上角拖過來時rtable - http://i.stack.imgur.com/474OP.jpg
似乎從相對於拖元件切換到絕對定位。拖動「禮」切換來自:
<li class="ui-state-default ui-draggable" style="position: relative; left: 52px; top: 9px;">Item 3</li>
這樣:
<li class="ui-state-default ui-draggable ui-sortable-helper" style="position: absolute; left: 67px; top: 91px; width: 80px; height: 20px;">Item 3</li>
當將可拖動的項目拖動到可排序對象。
這是從jQueryUI的1.8.12相關片段(開始於3041線):
//The element's absolute position on the page minus margins
this.offset = this.currentItem.offset();
this.offset = {
top: this.offset.top - this.margins.top,
left: this.offset.left - this.margins.left
};
// Only after we got the offset, we can change the helper's position to absolute
// TODO: Still need to figure out a way to make relative sorting possible
this.helper.css("position", "absolute");
this.cssPosition = this.helper.css("position");
$.extend(this.offset, {
click: { //Where the click happened, relative to the element
left: event.pageX - this.offset.left,
top: event.pageY - this.offset.top
},
parent: this._getParentOffset(),
relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
});
//Generate the original position
this.originalPosition = this._generatePosition(event);
this.originalPageX = event.pageX;
this.originalPageY = event.pageY;
有沒有我不使用某些配置選項?
CSS有問題嗎?
或者這是jqueryUI中的錯誤?
你鏈接到正確的小提琴?我在演示中看到了與截屏中不同的佈局。 – 2011-05-03 23:01:30
@Andrew:謝謝你指出。鏈接已被修復。 – 2011-05-03 23:16:11
看起來像JS不工作 - 仔細觀察它看起來像腳本期待不同的HTML?不確定。 – 2011-05-04 00:20:57