Twitter bootstrap 如何实现支持拖放的触摸敏感、响应灵敏、可排序列表;自动引导?

Twitter bootstrap 如何实现支持拖放的触摸敏感、响应灵敏、可排序列表;自动引导?,twitter-bootstrap,jquery-ui,touch,jquery-ui-sortable,rubaxa-sortable,Twitter Bootstrap,Jquery Ui,Touch,Jquery Ui Sortable,Rubaxa Sortable,我有一个列表,我想对其进行排序(拖放)。如何在现代浏览器和触摸设备中使用Bootstrap3 我尝试使用jqueryui sortable与;这似乎很有效,但它很粗糙,而且jQueryUI在引导方面做得不好 在添加触摸屏支持的同时,如何避免Bootstrap/jQueryUI冲突?我只是想发布一个@KyorCode的补充答案。我听从了他的建议,并接受了他的建议,这对我来说是天衣无缝的。我大概花了10分钟才把这件事做好 我不需要包含任何jQueryUICSS——只需要JavaScript——因此C

我有一个
列表,我想对其进行排序(拖放)。如何在现代浏览器和触摸设备中使用Bootstrap3

我尝试使用jqueryui sortable与;这似乎很有效,但它很粗糙,而且jQueryUI在引导方面做得不好


在添加触摸屏支持的同时,如何避免Bootstrap/jQueryUI冲突?

我只是想发布一个@KyorCode的补充答案。我听从了他的建议,并接受了他的建议,这对我来说是天衣无缝的。我大概花了10分钟才把这件事做好

我不需要包含任何jQueryUICSS——只需要JavaScript——因此CSS与引导程序没有任何冲突

工作示例:

<!-- Bootstrap 3 panel list. -->
<ul id="draggablePanelList" class="list-unstyled">
    <li class="panel panel-info">
        <div class="panel-heading">You can drag this panel.</div>
        <div class="panel-body">Content ...</div>
    </li>
    <li class="panel panel-info">
        <div class="panel-heading">You can drag this panel too.</div>
        <div class="panel-body">Content ...</div>
    </li>
</ul>
<style type="text/css">
    /* show the move cursor as the user moves the mouse over the panel header.*/
    #draggablePanelList .panel-heading {
        cursor: move;
    }
</style>
以下是www.bootply.com上的一篇文章

HTML:

<!-- Bootstrap 3 panel list. -->
<ul id="draggablePanelList" class="list-unstyled">
    <li class="panel panel-info">
        <div class="panel-heading">You can drag this panel.</div>
        <div class="panel-body">Content ...</div>
    </li>
    <li class="panel panel-info">
        <div class="panel-heading">You can drag this panel too.</div>
        <div class="panel-body">Content ...</div>
    </li>
</ul>
<style type="text/css">
    /* show the move cursor as the user moves the mouse over the panel header.*/
    #draggablePanelList .panel-heading {
        cursor: move;
    }
</style>

  • 可以拖动此面板。 内容。。。
  • 您也可以拖动此面板。 内容。。。
JavaScript:

<!-- Bootstrap 3 panel list. -->
<ul id="draggablePanelList" class="list-unstyled">
    <li class="panel panel-info">
        <div class="panel-heading">You can drag this panel.</div>
        <div class="panel-body">Content ...</div>
    </li>
    <li class="panel panel-info">
        <div class="panel-heading">You can drag this panel too.</div>
        <div class="panel-body">Content ...</div>
    </li>
</ul>
<style type="text/css">
    /* show the move cursor as the user moves the mouse over the panel header.*/
    #draggablePanelList .panel-heading {
        cursor: move;
    }
</style>
你可以在你的页面上

<!-- Assumes that JQuery is already included somewhere. Size: 22kb or 13kb minified. -->
<script src="/Scripts/jquery-ui-1.10.4.custom.js"></script>

<script type="text/javascript">
    jQuery(function($) {
        var panelList = $('#draggablePanelList');

        panelList.sortable({
            // Only make the .panel-heading child elements support dragging.
            // Omit this to make the entire <li>...</li> draggable.
            handle: '.panel-heading', 
            update: function() {
                $('.panel', panelList).each(function(index, elem) {
                     var $listItem = $(elem),
                         newIndex = $listItem.index();

                     // Persist the new indices.
                });
            }
        });
    });
</script>

jQuery(函数($){
var panelList=$(“#draggablePanelList”);
可排序的小组成员({
//仅使.panel标题子元素支持拖动。
//省略此项以使整个
  • 可拖动。 句柄:'.panel heading', 更新:函数(){ $('.panel',panelList).每个(函数(索引,元素){ 变量$listItem=$(元素), newIndex=$listItem.index(); //坚持新指数。 }); } }); });
  • CSS:

    <!-- Bootstrap 3 panel list. -->
    <ul id="draggablePanelList" class="list-unstyled">
        <li class="panel panel-info">
            <div class="panel-heading">You can drag this panel.</div>
            <div class="panel-body">Content ...</div>
        </li>
        <li class="panel panel-info">
            <div class="panel-heading">You can drag this panel too.</div>
            <div class="panel-body">Content ...</div>
        </li>
    </ul>
    
    <style type="text/css">
        /* show the move cursor as the user moves the mouse over the panel header.*/
        #draggablePanelList .panel-heading {
            cursor: move;
        }
    </style>
    
    
    /*当用户将鼠标移动到面板标题上时显示移动光标*/
    #DragablePanelist.面板标题{
    光标:移动;
    }
    

    HTH

    在此之前发布的答案出人意料地过时了

    是一个快速、无依赖性、小的可重排序列表小部件,支持触摸,可与HTML5本地拖放API一起使用。您可以在Bootstrap、基础或任何您想要的CSS库中使用它,而实例化它只需要一行。

    它支持在列表内或跨列表重新排序。您可以定义只能接收元素的列表,或者可以从中拖动但不能拖放的列表。它也非常积极地维护和维护

    new Sortable(document.getElementsByClassName('Sortable')[0])
    
    
    
    • 这是
    • 它与引导程序一起工作
    • …开箱即用
    • 它支持触摸设备
    • 只需拖动一些元素即可
    这是基于gridster制作的,-最初的版本是针对仪表板的,但您可能可以让它在常规的list@light24bulbs-刚在我的iPad上测试过,但它不起作用,可能是出于设计。。。老实说,我不喜欢在触摸设备上拖放,因为很难(不可能?)区分滚动动作和拖动动作。我使用JIRA进行bug跟踪,我对他们的界面感到不满的一点是,当我试图在iPad上滚动时,我不小心改变了问题的优先级,因为它允许将问题拖到优先级顺序。这是桌面上的一个很好的功能,但更好的触摸方式是在每一行上使用手指大小的向上/向下箭头。@Acentric为什么不使用和/或来区分滚动和拖动动作?@speendo-我在我的示例中使用手柄。这里有一个简短的讨论-但本质上它与滚动手势冲突,许多设备现在使用长触摸作为右键单击-因此延迟可能与此冲突。@Acentric fair。一个小警告-您可能会遇到一些名称空间冲突,同时运行jQuery UI和Bootstrap。您可以通过执行自定义jQuery UI导出并仅包含所需的功能(此处就是这种情况)或使用jQuery的“桥接”函数重命名与引导功能重复的jQuery UI函数来缓解此问题,例如“工具提示”和“按钮”。有关更多信息,请参阅。@FezVrasta:你是制作这个的Fez Vrasta吗?是的,我是developer@FezVrasta伟大的工具!