touch-dnd icon indicating copy to clipboard operation
touch-dnd copied to clipboard

Allowing cloned items to be dragged again.

Open christianmagill opened this issue 8 years ago • 4 comments

How can I allow cloned items to be dragged again once dropped in a droppable?

christianmagill avatar Apr 05 '16 01:04 christianmagill

I ended up using this.. If there's a cleaner way please let me know. Thanks

$('.draggable').draggable({
      clone: true,
   });

   $('.droppable').droppable({
      disabled: false,
      activeClass: 'active',
      hoverClass: 'drop-here'
   })
   .on('droppable:drop', function(e, ui){
      if(ui.clone){
         $(ui.clone[0]).draggable();
            console.log(ui);
          }
   });

christianmagill avatar Apr 05 '16 02:04 christianmagill

I also this bug was found. I think the event fires before the advent of the DOM element. <dragged-block></dragged-block> <droppable-block></dropable-block>

<style> dragged-block{display:block;width:100px;height:100px;background:#45729b;box-shadow:0 0 0 1px #fff;position:absolute;} droppable-block{display:block;width:500px;height:500px;background:#ccc;position:absolute;left:100px;} droppable-block>dragged-block{position:relative;display:inline-block;} </style>

<script src="js/jquery.js"></script> <script src="js/touch-dnd.js"></script> <script> $(window).load(function(){

$('dragged-block').draggable({clone:true});

$('droppable-block').droppable() .on('droppable:drop',function(){ setTimeout(function(){$('dragged-block').draggable({clone:true});},100); });

}); </script>

calebelt avatar Apr 05 '16 12:04 calebelt

I am not aware of a better solution. But, if your use cases permits this, you could use sortables and connect them together.

Would you consider the drop event being fired before the DOM element got rendered as an actual issue?

rkusa avatar Apr 06 '16 05:04 rkusa

Thanks

christianmagill avatar Apr 07 '16 04:04 christianmagill