Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Connected lists create duplicates when 'cancel' is called #146

Closed
43081j opened this issue Mar 24, 2014 · 5 comments
Closed

Connected lists create duplicates when 'cancel' is called #146

43081j opened this issue Mar 24, 2014 · 5 comments

Comments

@43081j
Copy link

43081j commented Mar 24, 2014

Example here.

Drag any item from one list to another.

When dealing with connected lists, if you call sortable('cancel') in the receive event, the item is moved back but appears in both lists. Doing this in jQueryUI alone works perfectly fine and I am unable to find what part of the code is causing this.

@43081j
Copy link
Author

43081j commented Mar 24, 2014

Also can someone explain what is happening here?

Drag an item to another list, it will be cancelled first time. Then drag the same item to the same list again, it will be cancelled even though there is no code telling it to, and another item gets randomly moved.

It appears on calling cancel(), the item is removed from the model but the element in DOM is put back.

@thgreasi
Copy link
Contributor

Take a look at #107. cancel() must be called inside the update callback of the originator sortable.
Otherwise some of the models will be updated causing the above behavior.
This (obviously) should be better documented.

@43081j
Copy link
Author

43081j commented Mar 24, 2014

Indeed.

So in my use case I need to cancel based on the sortable it came from, how is this possible within update seeing as there is no sender?

Edit:

droptarget :D

@thgreasi
Copy link
Contributor

Did you saw the final pen provided in #107.
ui.item.sortable.droptarget.attr('id') returns "screen-1" and event.target.id returns "screen-0".
Are these two enough for your use case?

@43081j
Copy link
Author

43081j commented Mar 24, 2014

Yup, I was able to use ui.item.sortable.droptarget. Thanks for the help, the documentation doesn't quite explain the properties of sortable it adds.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants