How to prevent multiple droppables jQuery UI from starting?

I have jQuery UI draggable and several separately defined droppables . Since one of the permutations is configured tolerance: 'intersect', it is possible that draggable can be reset to more than one droppable type at the same time.

What is the best way to prevent unintentional emissions? Basically, I would like to prioritize the drop-down folders so that when using tolerance: 'intersect'droppables they won’t start if another droppable was launched.

Update - additional information to clarify things:

  • All drop-down folders are configured tolerance: 'pointer'except for one droppable class tolerance: 'intersect'.

  • The reason one droppable class has tolerance: 'intersect'one is because droppables are really narrow, and users have trouble finding them using tolerance: 'pointer'.

  • Moving additional folders is not an option.

  • None of the overlapping folders overlap, but the dragged object is large enough to overlap droppable with tolerance: 'intersect', while the mouse pointer is over the other that is dumped with tolerance: 'pointer'. Thus, no more than two droppables can be launched.

  • The user interface is laid out so that user intentions can be determined by ignoring tolerance: 'intersect'droppable if another droppable has been called; that is, if the user has moved the mouse pointer over droppable with tolerance: 'pointer', it is safe to assume that he / she intended to reset it there. The problem is that I cannot figure out how to ignore unwanted droppable.

+5
source share
3 answers

In over:assign the class to the droppable being assigned and remove the class from all the other droppables:

$(".dragArea").not($(this)).removeClass("dragHover");
$(this).addClass("dragHover");

Then in drop:check if the class is installed:

if(!$(this).is('.dragHover')){
    return false;
}

Thus, only one droppable is launched.

+7
source

, " " droppable , "", " " droppable.

, .

+1

Move them physically far apart so that they cannot be dropped at the same time. Otherwise, how should you determine what was intended for the user? Are you going to calculate the drag percent on each intersecting droppable?

0
source

All Articles