Jquery 拖放,获取拖放的 CLONE 而不是常规拖放

Jquery drag and drop, get the dropped CLONE instead of the regular drop

我正在使用 jQuery 创建拖放页面。 使用下面的代码,您通常可以将放置的对象放入变量中。

  $("html").on("drop", function(event, ui) {
     event.preventDefault();  
     event.stopPropagation();
    var dropVar = $(ui.draggable);
    }

但是我使用:

 helper: "clone"

我创建的变量 dropVar 将包含普通的 dropobject,但我需要它包含克隆对象。

如何将删除的克隆放入变量中?

我的全部代码:

</head>
<body>
<div id="menu">
    <div class="titel p">
        p
    </div>
    <div class="titel h">
        h1
    </div>
    <div class="titel"><img height="60" id="block3" src="blue.png" width="150"></div>
    <div class="titel"><img height="60" id="block4" src="yellow.png" width="150"></div>
    <div class="titel"><img height="60" id="block5" src="pink.png" width="150"></div>
</div><br>
<table>
    <tr>
        <td>
            <div class="ui-sortable ui-droppable" id="droppable"></div>
        </td>
    </tr>
</table>
<script>
   var round = false;
   $(function() {

   $( ".draggable" ).draggable({
     connectToSortable: "#sortable",
     helper: "clone",
     revert: "invalid"
   });

   $(".titel").draggable({ 
       revert: "invalid",
       helper: "clone" 
   });   
   $("#droppable").droppable({
       activeClass: "ui-state-default",
       hoverClass: "ui-state-hover",
       drop: function(event, ui) {
           var newClone = $(ui.helper).clone();
           $(this).append(newClone);
       }
   });
   });

   $("html").on("drop", function(event, ui) {
   event.preventDefault();  
   event.stopPropagation();
    var hoi = $(ui.draggable);
    debugger;
    if(hoi.hasClass("p") && hoi.hasClass("ui-draggable-dragging")){
    alert("yo");
    hoi.innerHTML = "<p contenteditable='true'>type here<\/p>";
    }
   });

   $(document).click(function(e) {
       console.log(e);
       var el = $(e.target).parent();
       if(el.hasClass("ui-draggable-dragging")){
           el.hide();
       }

   })

   $(".ui-draggable-dragging").click(function(){
   $(this).hide();
   });

</script>

您应该能够通过以下方式访问辅助对象:

ui.helper[0]

如果有帮助请告诉我。