Search code examples
jqueryhtmljquery-uijquery-ui-draggablejquery-ui-resizable

jQuery resize() event is not working while draggable


I am trying to use jQuery to make "Draggable" into the DIV(id=sortable), but it's not working "Resize".

  1. Draggable "Drag me down" DIV into DIV(id=sortable)
  2. Draggable is working fine within the DIV(id=sortable)
  1. Resizable is not working within the DIV(id=sortable)

Does anyone know what I am doing wrong?

Script and HTML

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

  $('.resizemove').resizable();

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
  <div id="draggable" class="ui-state-highlight ui-state-default resizemove DivStyle" style="width:100px; height:100px; display:block; background: lightyellow;">Drag me down</div><br>
</div>

<div id="sortable" class="main-wrap" style="border:5px solid rgb(221, 221, 221);padding: 5px; clear: both;">
  <div class="ui-state-default resizemove DivStyle" style="width:100px; height:100px; display:block; background: lightbluered;">One</div>
  <div class="ui-state-default resizemove DivStyle" style="width:100px; height:100px; display:block; background: lightpink;">Two</div>
  <div class="ui-state-default resizemove DivStyle" style="width:100px; height:100px; display:block; background: lightgray;">Three</div>
  <div class="ui-state-default resizemove DivStyle" style="width:100px; height:100px; display:block; background: lightseagreen;">Four</div>
  <div style="clear:both"></div>
</div>

Here is the JsFiddle


Solution

  • I would adjust your Draggable Handle. For example:

      $("#draggable").draggable({
        connectToSortable: "#sortable",
        handle: $(this).not(".ui-resizable-handle"),
        helper: "clone",
        revert: "invalid"
      });
    

    Example: https://jsfiddle.net/Twisty/84cvchas/2/