好吧,我对 Jquery 可排序插件有一个奇怪的问题。我正在尝试在 overflow-y:auto
div 中制作一系列列表。当列表比容器小时,这很有效。然而,一旦列表增长并且容器溢出开始工作,可排序对象就不再真正工作了。当用户向下拖动列表时,它们不会向下滚动。
有谁知道如何将滚动或拖动事件附加到容器?我已经尝试在容器上设置 sortable 并使子句柄,但这不会触发我需要的“接收”事件。另外,滚动事件仍然无法正常工作。
这是我的插件是如何初始化的:
$('.sort-list').sortable({
'connectWith': '.item-container',
'items': ".item-wrapper:not(.main-item)",
'containment': '.canvas',
'placeholder' : "ui-state-highlight",
'scroll' : true,
'opacity' : 0.8,
start: function (event, div) {
// set the placeholder size to the proper size
$('.ui-state-highlight').css({
'width':$(div.helper).outerWidth()-2,
'height':$(div.helper).outerHeight()-2
});
},
receive: function(event, ui) {
var interval = $(event.target).parent('.time-container').attr('interval');
var oldInterval = $(ui.sender).parent('.time-container').attr('interval');
var item = $(ui.item).find('.item').data('objectData');
self.updateInterval(oldInterval, interval, item);
}
});
有没有人对让这种行为起作用有任何见解?我真的在这里被难住了......谢谢。
最佳答案
所以,为了所有正在寻找解决方案的人,我回答这个问题。不幸的是,当前的 Jquery UI sortable 是不可能的。我最终创建了一种不依赖于可排序滚动列表的不同行为。它基本上涉及对右侧每个列表的引用,并将列表中的元素拖动到该列表以更改它们所在的列表。希望能帮助别人。 :/
希望这会很快添加...
关于javascript - Jquery Sortable,在启用溢出的容器内使用链表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12144579/