Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to properly clone between Draggable #21

Closed
lucadegasperi opened this issue Oct 19, 2016 · 10 comments
Closed

How to properly clone between Draggable #21

lucadegasperi opened this issue Oct 19, 2016 · 10 comments

Comments

@lucadegasperi
Copy link

Hello, I've got 2 draggable components, from the first one objects can be cloned into the second draggable component. The problem Arises when cloning two object of the same type because they become interlinked (and changing data on one changes the data on the other) Is there a way to do a deep clone of one item?

@David-Desmaisons
Copy link
Member

Hello @lucadegasperi , could you provide a fiddle showing the current behaviour and explaining what you would expect? Thanks.

@lucadegasperi
Copy link
Author

Whoa, quick answer: Here's the fiddle: https://jsfiddle.net/32f7yu7c/ Try dragging one item from the list above to the list below and then click on the item in the list below. It will update the item in the list above as well (thus it's not a real cloning)

@David-Desmaisons
Copy link
Member

I understand what you are trying to do and currently vue.draggable is designed to use the same object when the clone option is used.
I think that an extra hook could be provided to let the user decide the stategy to clone the dragged element.

@lucadegasperi
Copy link
Author

lucadegasperi commented Oct 19, 2016

Would be awesome as I'm stuck with this problem.

Even without a hook, where should I look for to properly clone the object?

@David-Desmaisons
Copy link
Member

You should take a look at onDragAdd (evt) . That said I should provide the fix today or tomorrow.

@lucadegasperi
Copy link
Author

Guess I can wait that long :) Thanks!

@David-Desmaisons
Copy link
Member

Added the clone props to override the current cloning behaviour. See readme for documentation of this new function and this example: https://jsfiddle.net/dede89/dcvLufju/

@Sun11l
Copy link

Sun11l commented May 6, 2019

这个问题困扰了老子很久很久 百度搜索搜不到 换了谷歌搜索 一下子就出来了 牛批牛批 感谢作者!
Thaaaaaaaaaaaaaaks!!!!!!!!!!

@dhubbard-ag
Copy link

I found another pretty good example of "clone" https://codepen.io/getreworked/pen/zMzzQR?editors=1010

@Pijushgupta
Copy link

https://wpconstant.com/vue-draggable-one-to-many-clone-vue3/

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

No branches or pull requests

5 participants