Skip to content
This repository has been archived by the owner on Nov 27, 2019. It is now read-only.

Element events are not getting copied on copied element or on same element during drag operation #165

Open
contactsandygo opened this issue Sep 30, 2017 · 6 comments

Comments

@contactsandygo
Copy link

contactsandygo commented Sep 30, 2017

I am exploring dragular with following option
copy: true,
copySortSource: true
Events registered on original elements are not getting copied with these option.Please what approach can be used so that along with dom and scope, events also should get copied in this mode.
There are two issues

  1. Cloned element across containers does not have registered event of original element.
  2. Within same container element loose registered events

Please refer plunker created by me for these problems
https://plnkr.co/edit/geahyNnuZxFsuMLzFVER?p=preview

image
image

Regards,
San

@luckylooke luckylooke self-assigned this Oct 1, 2017
@luckylooke
Copy link
Owner

Cloning events is not so simple, there is no API for it in DOM. I dont want to wrap build-in methods mentioned here. So your option here is to register the events again on drop event, edited plunker here. Thanks for using dragular ;)

@luckylooke
Copy link
Owner

Aaa.. I have found better solution.. I can clone the element via jQlite which is part of angularjs core and it fully implements jQuery clone which has ability to clone event handlers too.. so I will add this feature in next release.. I will let you know here.

@contactsandygo
Copy link
Author

Thank you for taking up as feature request.

@luckylooke
Copy link
Owner

Yeah.. but it is a bit more complicated as I thought. jQLite does not attach the listeners to the cloned element, as I thought.. so I will look at this later. :/

@contactsandygo
Copy link
Author

I have support for JQuery in my project so I will use its clone method only issue with that is probably after registering new handler scope data would be still pointing towards original element as I wont be able to create fresh scope for cloned element with new values on droped event unless I use $compile service to create new element on fly and instead of attaching dragular cloned element use compiled element so visually it would appear as drag drop operation with source element intact.

Thanks for your support.

@luckylooke
Copy link
Owner

Yes, for now you need some workaround.. I will try to find some way how to list all events attached to element.

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

No branches or pull requests

2 participants