Skip to content
Advertisement

I Cannot drop generated elements

I am working on a website that can generate templates with drag and drop. I have made an element generator. But the problem is that I can only drag and drop the elements that are already in the “container” as an example ” already button” but the generated items are not droppable. I’m new to JavaScript so don’t know much about it. Please solve this problem. So I may continue to work on my website Here is my code

JavaScript

Please Help

Advertisement

Answer

You missed adding event handlers to the new elements. I modified your example by adding event handlers to a separate function initDraggable so that later it would be easier to use it when generating new elements.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement