【问题标题】:jquery ui sotable connected list items container + zinxed issuejquery ui可排序连接列表项容器+ z索引问题
【发布时间】:2013-10-30 05:21:05
【问题描述】:

我正在使用可通过连接列表排序的 jquery ui。 我有 2 个问题。

1.Drag Index:当项目从一个列表A拖到另一个列表B时,项目在拖动时在列表B后面,但一旦放下就正确显示。

2.容器滚动:当左侧列表中的项目被拖到右侧时,它不会先显示占位符,而是滚动容器然后出现在其他列表中。

JSFIDDLEhttp://jsfiddle.net/bababalcksheep/Cd4Sr/

类似: http://quasipartikel.at/multiselect_next/

HTML:

<div class="ui-splitselect ui-helper-clearfix ui-widget ui-widget-content">
    <div class="ui-widget-content ui-splitselect-selected" style="width: 50%;">
        <div class="ui-widget-header ui-helper-clearfix">
        </div>
        <ul id="sortable1" class="ui-splitselect-list" style="height: 200px;">
            <li class="ui-splitselect-item ui-state-default">
                <a class='ui-splitselect-handle-drag'><span class='ui-icon ui-icon-carat-2-n-s'></span></a>
                <span class="ui-splitselect-handle-select">Test1</span>
                <a class="ui-splitselect-handle-move" href="#"><span class="ui-icon ui-icon-plus"></span></a>
            </li>    
        </ul>
    </div>
    <div class="ui-widget-content ui-splitselect-available" style="width:49.8%;">
        <div class="ui-widget-header ui-helper-clearfix">
        </div>
        <ul id="sortable2" class="ui-splitselect-list" style="height: 200px;">
        </ul>
    </div>
</div>

CSS:

.ui-splitselect{font-size:.8em;width:100%!important;text-align:center;margin:0 auto;padding:0}
.ui-splitselect ul{-moz-user-select:none}
.ui-splitselect .ui-widget-header{border:none;font-size:11px}
.ui-splitselect-selected{float:left;border:none;margin:0;padding:0}
.ui-splitselect-available{float:left;border-top:none;border-bottom:none;border-right:none;margin:0;padding:0}
.ui-splitselect-list{position:relative;overflow:auto;overflow-x:hidden;list-style:none;width:100%;margin:0;padding:0}
.ui-splitselect-item{cursor:default;line-height:20px;height:20px;font-size:11px;list-style:none;display:list-item;white-space:nowrap;overflow:hidden;margin:1px;padding:0}
.ui-splitselect-item.ui-sortable-helper{z-index:99999}
.ui-splitselect-handle-select{float:left}
.ui-splitselect-handle-drag{float:left;height:20px;border-top:0;border-bottom:0;cursor:pointer;margin:0 10px 0 5px;padding:2px 5px}
.ui-splitselect-handle-move{text-decoration:none;cursor:pointer;float:right;height:20px;border-top:0;border-bottom:0;margin:0 5px 0 10px;padding:2px 5px}

【问题讨论】:

    标签: jquery css jquery-ui jquery-ui-sortable


    【解决方案1】:

    ui-splitselect-list 类中删除了 overflow: auto;overflow-x: hidden;。将类ui-splitselect 溢出设置为overflow-y: auto;

    这是更新后的>>>JSFiddle<<<

    CSS:

     .ui-splitselect {
        font-size: 0.8em;
        width:100% !important;
        padding: 0;
        margin: 0 auto;
        text-align:center;
        overflow-y: auto;    /*-----updated-----*/
    }
    .ui-splitselect-list {
        position: relative;
        padding: 0;
        margin: 0;
        list-style: none;
        /*-----updated  Removed overflow: auto;-----*/
        /*-----updated  Removed overflow-x: hidden;-----*/
        width: 100%;
    }
    

    jQuery:

     $("#sortable1, #sortable2").sortable({
         connectWith: ".ui-splitselect-list",
         containment: ".ui-splitselect",
         scroll: false,
         placeholder: "ui-state-highlight ui-splitselect-item"
     }).disableSelection();
    

    【讨论】:

    • 更新:如果我将项目向右倾斜,则会出现相同的容器问题。对于两个列表。
    • 您能否详细说明问题。
    • 功能似乎是正确的。拖动黄色占位符后,从当前位置移动到相对元素中的新位置。拖动的项目也显示在包含的元素上。不知道我错过了什么。
    • 尝试将一个项目拖到底部,容器 div 中断,尝试将一个项目从右侧列表拖到更右边,容器 div 发生滚动。
    • 如果有更多列表项,我需要滚动以仅显示 Y 方向。拖动时不应在 X 方向发生滚动。在您的情况下,如果我将项目拖动得太右,则会出现 X-dir 的滚动条。此外,当我将项目在底部移动得太远时,它会破坏容器 Div 边框。
    猜你喜欢
    • 1970-01-01
    • 2015-02-09
    • 2016-09-14
    • 1970-01-01
    • 1970-01-01
    • 2015-07-23
    • 2018-03-25
    • 2011-02-11
    相关资源
    最近更新 更多