jQuery resize()事件在可拖动时不起作用

时间:2018-02-01 07:08:55

标签: jquery html jquery-ui jquery-ui-draggable jquery-ui-resizable

我正在尝试使用jQuery将“Draggable”变成DIV(id = sortable),但它不能正常工作“Resize”。

  1. 可拖动“将我拖下来”DIV进入DIV(id = sortable)
  2. Draggable在DIV(id = sortable)
  3. 中正常工作
      
        
    1. Resizable在DIV(id = sortable)
    2. 中无法正常工作   

    有谁知道我做错了什么?

    脚本 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>

    以下是JsFiddle

1 个答案:

答案 0 :(得分:0)

我会调整你的可拖动手柄。例如:

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

示例:https://jsfiddle.net/Twisty/84cvchas/2/