1
$('.batch_listing').sortable({
forcePlaceholderSize: true,
forceHelperSize: true,
placeholder: 'photo_ghost',
helper: 'clone',
receive: function(event, ui)
{
if(!is_in_batch(ui.item.children("a").children("img").attr("data-photo-id")))
{
add_to_batch_dispatch(ui.item.children("a").children("img").attr("data-photo-id"));
} else {
//Remove from batch
$(this).sortable("cancel");
alert("shouldn't be added");
}
},
sort: function(event, ui) {
if(placing == false)
{
$(".destory_drop").fadeIn();
}
},
stop: function(event, ui) {
if(removing == false)
{
$(".destory_drop").fadeOut();
}
}
}).disableSelection();
我有一系列可连接到这种排序的可拖动。在接收回调中被忽略的可排序(“取消”)
$("#photo_browser li").draggable({
snap: false,
revert: 'invalid',
helper: 'clone',
appendTo: "body",
cursor: 'move',
opacity: 0.5,
connectToSortable: "ul.batch_listing",
start: function(e, ui){
placing = true;
},
stop: function(e, ui){
placing = false;
}
});
代码本身工作正常,is_in_batch和add_to_batch_dispatch,刚刚从记录的项目和检查ID,看它是否已经在可排序的存在。但是,每当我打电话给$(this).sortable("cancel")
时,可拖动的元素仍然会放入可排序的元素中(并且调用代码中的测试警报)。
最初,这确实在沿着它停止的线路的某个地方工作;我花了数小时试图找出原因,所以一些帮助将不胜感激。