我有一个元素列表,我想使用Jquery UI对其进行排序和调整大小。将它们结合在一起在Chrome和Firefox中效果很好。但在IE8中(从正常和兼容性的角度来看),单独使用时,这两种行为都很有效,但组合使用时,产生的混合行为是不可取的。
我的期望是通过拖动可调整大小的控制柄来调整元素的大小
不
同时激活可排序行为并移动该元素。不幸的是,当我拖动元素的调整大小区域时,它也会拖动元素,就像我在移动它的排序位置一样。我希望这两种行为是排他性的。以下是复制行为的代码:
<!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>
我尝试了几种策略来解决这个问题,包括:
-
上述方法试图在开始调整大小时禁用可排序。不幸的是,这根本没有效果。
-
使用resizable的start函数为项目添加一个类,然后使用该类的可排序过滤器(例如$(“#wrapper”).sortable({items:“.item:not(.resize)”});以及$(“#wrapper”).sortable({items:“.item”,cancel:“.resize”}); )
-
-
大量的谷歌搜索,在我的桌子上打我的头,并在微软的大方向上喃喃自语。