[英]jquery clone is not working on droppable
I have a div that i can drag to other div, and its working fine. 我有一个div,可以将其拖到其他div上,并且工作正常。
But with helper: 'clone', its possible to drag the div, but the droppable its not working. 但是使用helper:'clone',可以拖动div,但是droppable不起作用。
Do you know how to fix this? 你知道如何解决这个问题吗?
jquery: jQuery的:
$(function () {
$(".draggable").draggable({ helper: 'clone', revert: 'invalid' });
$(".droppable").droppable({
accept: ".draggable"
});
});
working example: http://jsfiddle.net/p21z4jy0/ 工作示例: http : //jsfiddle.net/p21z4jy0/
I think you are looking http://jsfiddle.net/p21z4jy0/2/ 我认为您正在寻找http://jsfiddle.net/p21z4jy0/2/
$(function () { $(".draggable").draggable({ helper: 'clone', revert: 'invalid' }); $(".droppable").droppable({ accept: function(drag) { var dropId = $(this).attr('data-id'); var dragId = $(drag).attr('data-id'); return dropId === dragId; }, drop: function (event, ui) { $('.droppable').append(ui.draggable); } }); });
.draggable{ width:100px; border: 1px solid green; } .droppable { width: 300px; height: 100px; margin: 10px; border: 1px solid green; } .draggable { height:50px; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/i18n/jquery-ui-i18n.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="draggable" data-id='a'>draggable a</div> <div class="droppable" data-id='a'>droppable a</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.