AshesOfOwls / jquery.shapeshift

A dynamic grid system with drag and drop functionality.
http://ashesofowls.github.com/jquery.shapeshift/
MIT License
1.67k stars 311 forks source link

Drag/drop never initialized for added elements #34

Open jpellerin opened 11 years ago

jpellerin commented 11 years ago

Elements added to a shapeshifted container can be placed with rearrange, but drag and drop is not enabled for the new elements. It appears that it is only set up during initialization, when enableDrapNDrop is called.

AshesOfOwls commented 11 years ago

Ah yeah, Ill have to add in some way to create elements through Shapeshift. I'll let you know what I come up with.

jpellerin commented 11 years ago

IMO adding the elements to the DOM and triggering an event is a good interface (works well with knockoutjs, for one thing) -- the problem is that the initialization steps for new elements are different during creation vs subsequent rearrange. Maybe just moving the enableDragNDrop call into render or arrange and keeping track of which elements have already been initialized would be enough?

AshesOfOwls commented 11 years ago

That would work but arrange is already a process hog so I'm weary on attaching it on top. I can see how arrange would be the easiest function to attach it to since you would have to call arrange when adding a new element anyway.

I also just thought of a new use case. Say a user drops a draggable item into a new container, and that new container has drag disabled. That dropped element then should have draggable destroyed on itself.

I'm thinking that it should be a new function, possible within arrange, that detects the number of elements within the container. If the number is higher than before, check the new items and do the necessary logic.

jpellerin commented 11 years ago

That does make more sense that reprocessing the draggability everything on every arrange.

On Mon, Apr 29, 2013 at 6:20 PM, Scott Elwood notifications@github.comwrote:

That would work but arrange is already a process hog so I'm weary on attaching it on top. I can see how arrange would be the easiest function to attach it to since you would have to call arrange when adding a new element anyway.

I also just thought of a new use case. Say a user drops a draggable item into a new container, and that new container has drag disabled. That dropped element then should have draggable destroyed on itself.

I'm thinking that it should be a new function, possible within arrange, that detects the number of elements within the container. If the number is higher than before, check the new items and do the necessary logic.

— Reply to this email directly or view it on GitHubhttps://github.com/McPants/jquery.shapeshift/issues/34#issuecomment-17198397 .

AshesOfOwls commented 11 years ago

Added this to version 2.1

AshesOfOwls commented 11 years ago

I am going to be just doing full version releases, so I am moving this to 3.0 which will be the next release.