Have been working to handle an edge case where dropping an item fails. I am processing a request on the server side using onDrop and if the server throws an error, I would like to "undo" the drop so the item does not stick in the destination container, but effectively moves back to the container it was dragged from.
I looked at the only other issue similar to this, which was closed some time ago, but it doesn't appear to work. I have also tried detaching the item from the container it was dropped in, and then calling _super but this doesnt work either.
onDrop: function ($item, container, _super) {
$.request('onDropItem', {
error: function(jqXHR, textStatus, errorThrown) {
// revert/undo the drop here
_super($item, container.rootGroup.itemContainer);
})
}
I believecontainer.rootGroup.itemContainer is a reference to the container the item was selected from? I thought calling _super() is what performs the actual drop?
Out of desperation, I thought maybe just using the same code from onDrop when it is successful, but using container.rootGroup.itemContainer would do it, but this hasn't worked either:
var $clonedItem = $("<li/>").css({ height: 0 });
$item.before($clonedItem);
$clonedItem.animate({ height: $item.height() });
$item.animate($clonedItem.position(), function () {
$clonedItem.detach();
_super($item, container.rootGroup.itemContainer);
});
Has anyone implemented this functionality before? Am I correct that container.rootGroup.itemContainer is a reference to the container the item originated from?
Have been working to handle an edge case where dropping an item fails. I am processing a request on the server side using
onDrop
and if the server throws an error, I would like to "undo" the drop so the item does not stick in the destination container, but effectively moves back to the container it was dragged from.I looked at the only other issue similar to this, which was closed some time ago, but it doesn't appear to work. I have also tried detaching the item from the container it was dropped in, and then calling
_super
but this doesnt work either.I believe
container.rootGroup.itemContainer
is a reference to the container the item was selected from? I thought calling_super()
is what performs the actual drop?Out of desperation, I thought maybe just using the same code from
onDrop
when it is successful, but usingcontainer.rootGroup.itemContainer
would do it, but this hasn't worked either:Has anyone implemented this functionality before? Am I correct that
container.rootGroup.itemContainer
is a reference to the container the item originated from?Any feedback is appreciated!