0

由于我使用的是 jQuery UI 的可排序扩展 nestedSortable,因此我试图创建多个(连接的)列表,每个列表在最大嵌套级别中都有单独的选项。但是插件会检查原始项目(被拖动)中的最大级别数量,而不是应该放置它的位置。

<script type="text/javascript"> 
_isAllowed: function(parentItem, levels) {
    var o = this.options;
    // Are we trying to nest under a no-nest or are we nesting too deep?
    if (parentItem == null || !(parentItem.hasClass(o.disableNesting))) {
        if (o.maxLevels < levels && o.maxLevels != 0) {
            this.placeholder.addClass(o.errorClass);
            this.beyondMaxLevels = levels - o.maxLevels;
        } else {
            this.placeholder.removeClass(o.errorClass);
            this.beyondMaxLevels = 0;
        }
    } else {
        this.placeholder.addClass(o.errorClass);
        if (o.maxLevels < levels && o.maxLevels != 0) {
            this.beyondMaxLevels = levels - o.maxLevels;
        } else {
            this.beyondMaxLevels = 1;
        }
    }
}
</script>

我如何才能使插件的这一部分选择项目被放置位置的 maxLevel 选项?

4

1 回答 1

1

我做了一个快速(肮脏的)修复来解决问题:

<script type="text/javascript"> 
_isAllowed: function(parentItem, levels) {
    var o = this.options;
    o.maxLevels=$(this.placeholder[0]).closest('.ui-sortable').nestedSortable("option","maxLevels");
</script>
于 2012-05-18T17:00:06.110 回答