观察以下示例:
<html>
<head>
<script src="jquery-1.6.2.js"></script>
<script src="jquery-ui-1.10.0.js"></script>
<script src="fixedsortable.js"></script>
</head>
<body>
<ul class="list-1">
<li class="fixed">Fruits</li><!-- responds as expected (it lives at the top level)-->
<li>
<ul class="list-2">
<li class="fixed">-Tomatoes are fruits too!</li><!-- not as expected, should act like a handle to sort the entire list of tomatoes within the list of fruits (as if it were a child element of a sortable item) -->
<li>--cherry tomatoes</li>
<li>--plum tomatoes</li>
<li>--roma tomatoes</li>
</ul>
</li>
<li>-oranges</li>
<li>-cherries</li>
<li>-bananas</li>
</ul>
<script>
$('[class*="list-"]').fixedsortable({
fixed: ".fixed"
});
</script>
</body>
</html>
可以在这里找到fixedsortable.js 扩展: 问题#4299241
我发现了以下关于 fixedsortable 扩展的信息:
...
},
_mouseStart: function( event ) {
for(var i=0;i<this.options.fixed.length;++i) {
var num = this.options.fixed[i];
var elem = this.items[num];
if(event.target == elem.item.get(0)) return false;
}
return $.ui.sortable.prototype._mouseStart.apply(this,arguments);
},
...
我尝试通过 DOM 向上event.target.parentNode
查找任何其他可排序对象,并将找到的任何内容作为 jquery 代替原型this
传递arguments
给原型,否则在到达文档时返回 false,但不清楚应该如何完成或是否这样做是正确的做法。
任何帮助将不胜感激!