[jQuery] ui.sortable: canceling animation on drag out
Hello there,
I have a sortable list plus a tree whose elements are drop targets. If
an element of the list is droppen to a tree node, I remove the element
from the list. The problem is that I use revert=true for the sortable
and the element flies back to its place even if it's removed. Is there
a way to cancel that?
$('#productlist').sortable({scroll: true, update: saveSequence,
handle: '#producticon', revert: true, opacity: 0.5});
$("#sectiontree").SimpleTree({click: onSectionTreeClicked, animate:
true});
$("#sectiontree span").droppable({accept: function() {return true;},
drop: onProductDropped, tolerance: 'pointer', hoverClass:
'sectiontreedrophover'});
this gets called on node dropping:
function onProductDropped(element, ui)
{
nTargetSectionID = $(ui.element).attr('ID').substring(8);
if (nSectionID != nTargetSectionID)
{
bDropMode = true;
nProductID = $(ui.draggable).attr('id').substring(5);
$(ui.draggable).remove();
$('#productlist').sortable('refreshPositions');
$.get('/admin/product/moveproduct', {nProductID: nProductID,
nTargetSectionID: nTargetSectionID});
}
}
And this is called on ending list sorting. This always gets called,
that's why the flag is needed, would be good if I could notify
sortable in the previous function to cancel the whole sorting thing.
function saveSequence(element, ui)
{
if (!bDropMode)
{
$.get("/admin/product/ajaxsavesequence?" + $
("#productlist").sortable('serialize'));
}
$bDropMode = false;
}