When I make a draggable clone and drop it in a droppable I cannot drag it again

后端 未结 4 552
执念已碎
执念已碎 2020-11-28 20:52

When I make a draggable clone and drop it in a droppable I cannot drag it again. How do I do that? Secondly I can only figure out how to us .append to add the c

4条回答
  •  我在风中等你
    2020-11-28 21:29

    One way to do it is:

    $(document).ready(function() {
        $("#container").droppable({
            accept: '.product',
            drop: function(event, ui) {
                $(this).append($("ui.draggable").clone());
                $("#container .product").addClass("item");
                $(".item").removeClass("ui-draggable product");
                $(".item").draggable({
                    containment: 'parent',
                    grid: [150,150]
                });
            }
        });
        $(".product").draggable({
            helper: 'clone'
        });
    });
    

    But I'm not sure if it is nice and clean coding.

提交回复
热议问题