luckylooke / dragular

Angular drag and drop based on dragula.js. Visit
http://luckylooke.github.io/dragular/
MIT License
209 stars 67 forks source link

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

Open contactsandygo opened 6 years ago

contactsandygo commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Thank you for taking up as feature request.

luckylooke commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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