Bootstrap jquery可排序只排序行?

时间:2017-09-20 18:32:15

标签: javascript jquery twitter-bootstrap jquery-ui

我一直在尝试使用引导网格按钮进行排序。它是一个响应式设计,多行包含3个按钮。我可以打开整个容器上的可排序,这让我可以拖放按钮,但它可以完成整行。我希望能够选择单个按钮并将它们拖放到其他行。我想是

$("buffer0,#buffer1,#buffer2").sortable({
     connectWith: "#buffer0,#buffer1,#buffer2"
}) 

会起作用,但这不允许任何拖放。我创造了一个小提琴,展示了它是如何工作的。 (调整输出屏幕的大小,以便您可以看到行)

真的很感激任何见解,一直盯着这几个小时,不知道去哪里。

https://jsfiddle.net/7yhkp9eo/2/

1 个答案:

答案 0 :(得分:0)

您可以使用:

  

items:指定元素中的哪些项目应该是可排序的。

  

tolerance:指定用于测试正在移动的项目是否悬停在另一个项目上的模式。可能的值。



$("#list_content").sortable({
    tolerance: "pointer",
    items: ".col-sm-4"
});
$("#list_content").disableSelection();

@import url('//netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css');

body {
    margin: 10px;
}

<link href="https://code.jquery.com/ui/1.12.0/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>


<div id="list_content">
    <div id="buffer0" class="row top-buffer">
        <div id="row0" class="col-sm-12 col-sm-offset-0 col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
            <div class="col-sm-4">
                <a link-type="c" href="#0,1" class="btn btn-default btn-lg btn-block btn-list  navbutton-padding"
                   role="button" data-original-title="" title=""><i class="fa fa-tasks icon-larger fa-2x fa-fw"></i>T11</a>
            </div>
            <div class="col-sm-4">
                <a link-type="c" href="#0,2" class="btn btn-default btn-lg btn-block btn-list  navbutton-padding"
                   role="button" data-original-title="" title=""><i class="fa fa-tasks icon-larger fa-2x fa-fw"></i>T12</a>
            </div>
            <div class="col-sm-4">
                <a link-type="c" href="#0,3" class="btn btn-default btn-lg btn-block btn-list  navbutton-padding"
                   role="button" data-original-title="" title=""><i class="fa fa-tasks icon-larger fa-2x fa-fw"></i>T13</a>
            </div>
        </div>
    </div>
    <div id="buffer1" class="row top-buffer">
        <div id="row1" class="col-sm-12 col-sm-offset-0 col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
            <div class="col-sm-4">
                <a link-type="c" href="#0,4" class="btn btn-default btn-lg btn-block btn-list  navbutton-padding"
                   role="button" data-original-title="" title=""><i class="fa fa-tasks icon-larger fa-2x fa-fw"></i>T21</a>
            </div>
            <div class="col-sm-4">
                <a link-type="c" href="#0,5" class="btn btn-default btn-lg btn-block btn-list  navbutton-padding"
                   role="button" data-original-title="" title=""><i class="fa fa-tasks icon-larger fa-2x fa-fw"></i>T22</a>
            </div>
            <div class="col-sm-4">
                <a link-type="c" href="#0,6" class="btn btn-default btn-lg btn-block btn-list  navbutton-padding"
                   role="button" data-original-title="" title=""><i class="fa fa-tasks icon-larger fa-2x fa-fw"></i>T23</a>
            </div>
        </div>
    </div>
    <div id="buffer2" class="row top-buffer">
        <div id="row2" class="col-sm-12 col-sm-offset-0 col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
            <div class="col-sm-4">
                <a link-type="c" href="#0,7" class="btn btn-default btn-lg btn-block btn-list  navbutton-padding"
                   role="button" data-original-title="" title=""><i class="fa fa-tasks icon-larger fa-2x fa-fw"></i>T31</a>
            </div>
            <div class="col-sm-4">
                <a link-type="c" href="#0,8" class="btn btn-default btn-lg btn-block btn-list  navbutton-padding"
                   role="button" data-original-title="" title=""><i class="fa fa-tasks icon-larger fa-2x fa-fw"></i>T32</a>
            </div>
            <div class="col-sm-4">
                <a link-type="c" href="#0,9" class="btn btn-default btn-lg btn-block btn-list  navbutton-padding"
                   role="button" data-original-title="" title=""><i class="fa fa-tasks icon-larger fa-2x fa-fw"></i>T33</a>
            </div>
        </div>
    </div>
</div>
&#13;
&#13;
&#13;