mcm-ham / dragsort

jQuery List DragSort
2 stars 1 forks source link

dragEnd callback doesn't always fire when it should #8

Open mcm-ham opened 6 years ago

mcm-ham commented 6 years ago

The example html page provided with your code doesn't provide for a situation where this can occur but there is a fundamental flaw in the code: The dragEnd callback only fires when the item being dragged has it's order changed (either within it's own list, or within the new list that it is being dragged to).   The documentation says: "dragEnd: The callback function that will be called after the dragging has ended."   Unforunately this is not true. If you want to see a situation where it doesn't work that way, setup a page where there are is a master list containing a couple draggable item's in it, and then a couple of other empty lists that can be dragged to/from, but which don't have any items in them to begin with. Setup the dragEnd callback to show an alert so that you know when it's being fired. Drag one of the items from the master list to one of the empty lists, notice the callback fires. Now drag that same item from the new list that it's a child of, to another one of the empty lists. Notice the callback doesn't fire, even though the item was moved!   The bug occurs because the dropEnd callback is only set to fire when one or more of the items has it's order changed within a list. The callback should always fire if an item is dragged from one destination to another, regardless of whether the order changes. Otherwise, if you only have a few items and a bunch of possible destinations, the dropEnd callback won't get fired when expected (if at all).   I patched the code so that it functions in the way I desired and I have attached the patch here. Thanks for the script, let me know if anyone has any questions.

Attachments

jquery.dragsort-0.4.3_patched.js

This work item was migrated from CodePlex

CodePlex work item ID: '31969' Vote count: '1'

mcm-ham commented 6 years ago

[mcm_ham@25/02/2012] Thanks for reporting this, this is now fixed in 0.5.1.

** Closed by mcm_ham 2/25/2012 2:27 AM

mcm-ham commented 6 years ago

[mcm_ham@25/02/2012]