文章目录
使用jQuery UI 拖动控件克隆后继续能拖动,代码如下:
1 2 3 4 5 6
| <div class="form-group" style="float:left;"> <input type="text" id="form-field-1" placeholder="input" class="col-xs-10 col-sm-5"> </div>
<div class="widget-main" style="height:800px;"></div>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| $(".form-group").draggable({ appendTo: ".widget-main", helper: "clone", revert: "invalid", cursor: "move" }); $( ".widget-main" ).droppable({ activeClass: "bg", hoverClass: "", accept: ".form-group", drop: function(event, ui) { $(ui.helper).clone().appendTo($(this)).draggable({appendTo: ".widget-main",revert: "invalid"}); $(ui.helper).remove(); } }).sortable({ items: "li:not(.placeholder)", sort: function() { $(this).removeClass("ui-state-default"); } });
|