Open geekrulez247 opened 12 years ago
Yes, some code would be great. Even better a jsFiddle example. And best of all a breaking test! Tried reproducing it but it seems like a lot ;)
here is the jsfiddle: http://jsfiddle.net/WB4U2/
drop2 is enabled the first time -> all fine drop2 gets disabled the second time -> all fine drop2 gets not init when the drag is dragged the third time -> bug?
I would like to disable a certain drop with cancel for ONE (the ongoing) drag.
Thanks for your comment!
I have different kinds of Drag-Drop-Operations in my app. Situation: Lot's of DropInit-Listeners are waiting for a Drag to call the DropInits. (SVG-Diagramming App.)
The drag-Object transports some semantic information, so every DropInit can decide to call the "drop.cancel()" method. Some DropInits will call the cancel method some won't call it. That's fine, because some want to take part in the upcoming DragDrop-Operation and some won't.
Problem: The next time a DragInit is done the DropInits of my previously "canceled" Drops are not informed. So the drop.cancel() canceles the DropHandlers forever (?)
Is this the desired behaviour? I would like to cancel the Drop just for the next upcoming DragDrop.
Cause: When a Drop is cancelled it is removed from the newElems-Array in the Drop.add() method. By this these cancelled Drops are not added to this._elements (which is fine). BUT, when cleaning up after the DragDrop the clean() Method just removes the $.data() from all this._elements. By this: In the next Drag-Operation the addCallbacks() method returns FALSE, because an $.data() element is already connected (origData !== null). By this, the old cancelled Drops will not take part in any upcoming Drags, because they are not added the the newElems-Array :(
Solution: I added a similar array like this._elements to the $.Drop and called it this._cancelledElements. In the add() method if (drop._cancelled === true) I add the current Elem to this array. Further I added the $.data() cleanup code for this new array in the clean() method. Works fine.
I could post the code if this will help?
Cheers!