jQuery UI: Drag and clone from original div, but keep clones

前端 未结 4 1955
故里飘歌
故里飘歌 2020-12-15 04:37

I have a div, which has jQuery UI Draggable applied. What I want to do, is click and drag that, and create a clone that is kept in the dom and not removed when dropped.

4条回答
  •  长情又很酷
    2020-12-15 05:08

    If you're tring to move elements (say

  • ) from a #source
      to a #destination
        , and you'd like them to clone (as opposed to move), and still be sortable on the right, I found this solution:

        $(function() {
        
            $("#source li").draggable({
                connectToSortable: '#destination',
                helper: 'clone'
            })
        
            $("#destination").sortable();
        
          });
        

        I know it seems ultra simple, but it worked for me! :)

提交回复
热议问题