Unable to create draggable and resizable cloned div

Viewed 57

I am creating layout where I want multiple div that should be draggable and resizable.

Till now I have tried this

$(".draggable").draggable({
  helper: "clone",
  cursor: 'move'
});

$('.droppable').droppable({
  accept: '.draggable',
  drop: function(e, ui) {
    $(ui.helper).clone(true).appendTo($(this));
  }
});

$(function() {
  $(".resizable").resizable();
});
.draggable {
  width: 150px;
  height: 150px;
  padding: 0.5em;
}

.resizable {
  width: 150px;
  height: 150px;
  padding: 0.5em;
}

.resizable h3 {
  text-align: center;
  margin: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

<div class="card-body droppable">
  <div class="ui-widget-content resizable draggable">
    <p>Drag me around</p>
  </div>
</div>

My code is giving me cloned div but they are fixed at one position I want them to be draggable and resizable.

Thank you for the help.

0 Answers
Related