Jquery Draggable - How do I create a new draggable div on the fly that can then be dragged?

后端 未结 2 720
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-09 01:26

I\'m creating a day planner using jquery, draggable and droppable.

When a job is dragged from the unassigned column into a hour time slot, the original draggable item i

相关标签:
2条回答
  • 2021-02-09 01:38

    Simply apply draggable to the newly created DIV. If the DIV is exactly the same, except for position, you could also not recreate it, but just reposition it. This would retain all of it's handlers.

     // remove, reposition, reapply handlers
     $('#jobN').remove().appendTo('#dayViewN').draggable();
    

    or

     // reposition, retain handlers
     $('#jobN').appendTo('#dayViewN');
    
    0 讨论(0)
  • 2021-02-09 01:46

    Rather than replacing the new div, why not disable the draggable?

    $(element).draggable('disable');
    

    Then when you want it to be draggable agian, use this

    $(element).draggable('enable');
    
    0 讨论(0)
提交回复
热议问题