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

前端 未结 4 1834
故里飘歌
故里飘歌 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:11

    Here is what I finally did that worked:

    $(".box-clone").live('mouseover', function() {
        $(this).draggable({ 
            axis: 'y',
            containment: 'html'
        });
    });
    $(".box").draggable({ 
        axis: 'y',
        containment: 'html',
        helper: 'clone',
        stop: function(event, ui) {
            $(ui.helper).clone(true).removeClass('box ui-draggable ui-draggable-dragging').addClass('box-clone').appendTo('body');
        }
    });
    

提交回复
热议问题