Zhengquan Bai
Zhengquan Bai

Reputation: 1073

Why can't I drag the div after I specify helper: "clone"

http://jsbin.com/xidoruheti/edit?html,css,js,output

According to the api:http://api.jqueryui.com/draggable/#option-helper

I don't know why the div becomes undraggable after I specifies helper: 'clone'

Upvotes: 1

Views: 118

Answers (1)

Pavan Teja
Pavan Teja

Reputation: 3202

try this. actually drag is working,but you are not able to see the element.because you specified the styles for #id but while dragging using clone option,plugin will remove id attribute.so you are unable to see the element being dragged.

$("#toDrag").draggable({
  helper: "clone"
});

$("#toDragId").draggable({
  helper: "clone",
  start: function(e, u) {
    $(u.helper).attr("id", "toDragId");
  }
});
.clone,
#toDragId {
  width: 100px;
  height: 100px;
  background: blue;
}
#toDragId {
  width: 100px;
  height: 100px;
  background: green;
}
<link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

<div id="toDrag" class="clone"></div>
<br>
<div id="toDragId"></div>

Upvotes: 2

Related Questions