JQuery UI in IE8: pause sorting when resizing an element that you can sort and resize

I have a list of elements that I would like to make sortable and resizable using jQuery UI. Combining them works fine in Chrome and Firefox. But in IE8 (both in normal mode and in compatibility mode), any behavior works fine when used separately, but when combined, the resulting mixed behavior is undesirable.

My expectation is that resizing an element by dragging and dropping resizable handles will also not activate the sortable behavior and move that element. Unfortunately, when I drag the element’s resizing areas, it also drags the element as if I were moving its sort position. I want both behaviors to be exclusive. Here is the code that replicates the behavior:

<!DOCTYPE html>
<html>
<head>
  <link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
  <script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
  <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
  <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.resizable.js"></script>
  <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.sortable.js"></script>

  <style type="text/css">
    .item { width: 200px; height: 20px; border: 1px solid gray; float: left; }
  </style>
  <script type="text/javascript">
  $(document).ready(function(){

    $(".item").resizable({
      start:function() {
        $("#wrapper").sortable("disable");
      },
      stop:function() {
        $("#wrapper").sortable("enable");
      }
    });
    $("#wrapper").sortable({
      items:".item"
    });
  });
  </script>
</head>
<body>
  <div id="wrapper">
    <div class="item">a</div><div class="item">b</div><div class="item">c</div><div class="item">d</div>
  </div>
</body>
</html>

I tried several strategies to solve this problem, including:

  • The above approach, which tries to disable sorting when resizing starts. Unfortunately, this has no effect.
  • (, $( "# wrapper" ). sortable ({items: ". item: not (.resize)" }) $( "# wrapper" ). sortable ({items: ". item", cancel: ". resizing" });)
  • googling, Microsoft.

.

+3
2

, span div.

.

, , , , !

+2

, . , , .

css javascript .

<!doctype html>
<html lang="en">
<head>
    <title>jQuery UI Resizable - Default functionality</title>
    <link type="text/css" href="/jquery/css/smoothness/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
    <script type="text/javascript" src="/jquery/js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="/jquery/js/jquery-ui-1.7.2.custom.min.js"></script>
    <style type="text/css">
        #draggable { border:solid 1px black; width: 75px; height: 150px; padding: 0.5em; }
        #resizable { border:solid 1px black; width: 75px; height: 150px; padding: 0.5em; }
        #resizable h3 { text-align: center; margin: 0; }
        #sortable { list-style-type: none; margin: 0; padding: 0; }
        #sortable li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; font-size: 1.4em; width: 100px; background-color:#CCC;border:solid 1px black;}
        </style>
        <script type="text/javascript">
        $(function(){$("#sortable").sortable({handle: 'span'});});
        $(function(){$("#item1").resizable();});
        $(function(){$("#item2").resizable();});
        $(function(){$("#item3").resizable();});
        </script>
    </head>
    <body>
    <div>
        <ul id="sortable">
            <li id="item1" class="ui-state-default"><span>Item 1</span></li>
            <li id="item2" class="ui-state-default"><span>Item 2</span></li>
            <li id="item3" class="ui-state-default"><span>Item 3</span></li>
        </ul>
    </div>
</body>
</html>
0

Source: https://habr.com/ru/post/1712227/


All Articles