Jquery 你觉得怎么样?听起来是个好主意,但我不知道该怎么做:)我想就是这样!我现在不在工作,但我会仔细看看tormorrow,greatany如何扩展占位符,所以如果我选择2项,我的占位符将有2个标签?我该如何给予赏金?@Ruben:亲爱的,代码请查看更新的答案,

Jquery 你觉得怎么样?听起来是个好主意,但我不知道该怎么做:)我想就是这样!我现在不在工作,但我会仔细看看tormorrow,greatany如何扩展占位符,所以如果我选择2项,我的占位符将有2个标签?我该如何给予赏金?@Ruben:亲爱的,代码请查看更新的答案,,jquery,jquery-ui,jquery-ui-sortable,selectable,Jquery,Jquery Ui,Jquery Ui Sortable,Selectable,你觉得怎么样?听起来是个好主意,但我不知道该怎么做:)我想就是这样!我现在不在工作,但我会仔细看看tormorrow,greatany如何扩展占位符,所以如果我选择2项,我的占位符将有2个标签?我该如何给予赏金?@Ruben:亲爱的,代码请查看更新的答案,赏金请阅读此。注:如果您愿意,还可以检查顶部箭头和giv a+1;-)这对我来说非常有效,但是对于大量的行,排序非常慢,有时会超时。为什么呢? // disables text selection on sortable, draggable


你觉得怎么样?听起来是个好主意,但我不知道该怎么做:)我想就是这样!我现在不在工作,但我会仔细看看tormorrow,greatany如何扩展占位符,所以如果我选择2项,我的占位符将有2个标签?我该如何给予赏金?@Ruben:亲爱的,代码请查看更新的答案,赏金请阅读此。注:如果您愿意,还可以检查顶部箭头和giv a+1;-)这对我来说非常有效,但是对于大量的行,排序非常慢,有时会超时。为什么呢?
// disables text selection on sortable, draggable items 
$( ".sortable" ).sortable();
$( ".sortable" ).disableSelection();
sort : function(event, ui) {
    var $helper = $('.ui-sortable-helper'), hTop = $helper.offset().top, hStyle = $helper.attr('style'), hId = $helper.attr('id');
    if (first_rows.length > 1) {
        $.each(first_rows, function(i, item) {
            if (hId != item.id) {
                var _top = hTop + (26 * i);
                $('#' + item.id).addClass('ui-sortable-helper').attr('style', hStyle).css('top', _top);
            }
        });
    }
},
start : function(event, ui) {
    if (ui.item.hasClass('ui-selected') && $('.ui-selected').length > 1) {
        first_rows = $('.ui-selected').map(function(i, e) {
            var $tr = $(e);
            return {
                tr : $tr.clone(true),
                id : $tr.attr('id')
            };
        }).get();
        $('.ui-selected').addClass('cloned');
    }
    ui.placeholder.html('<td colspan="99">&nbsp;</td>');
},
stop : function(event, ui) {
    if (first_rows.length > 1) {
        $.each(first_rows, function(i, item) {
            $(item.tr).removeAttr('style').insertBefore(ui.item);
        });
        $('.cloned').remove();
        first_rows = {};
    }
    $("#uber tr:even").removeClass("odd even").addClass("even");
    $("#uber tr:odd").removeClass("odd even").addClass("odd");
}
$( "#list" )
  .sortable({ handle: ".handle" })
  .selectable()
  .find( "li" )
  .addClass( "ui-corner-all" )
  .prepend( "<div class='handle'><span class='ui-icon ui-icon-carat-2-n-s'></span></div>" );
<!DOCTYPE html>
<html>
<head>
    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>

    <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.2/themes/cupertino/jquery-ui.css" />

    <style>
        #list {
            list-style: none;
            padding-left: 0;
        }

        #list .sort-handle {
            display: none;
        }

        #list .ui-selected .sort-handle
         {
            display: inline;
            padding: 0 0.5em;
            cursor: pointer;
        }

        li.ui-selected {
            background-color: #8888cc;
            color: white;
            font-weight: bold;
            background-image: none;
        }
        li.ui-selecting {
            background-color: #ccccff;
            color: white;
            background-image: none;
        }

    </style>
</head>
<body>
    <ul id="list">
        <li class="ui-widget-content"><span class="sort-handle">&#8225;</span>Item 1</li>
        <li class="ui-widget-content"><span class="sort-handle">&#8225;</span>Item 2</li>
        <li class="ui-widget-content"><span class="sort-handle">&#8225;</span>Item 3</li>
        <li class="ui-widget-content"><span class="sort-handle">&#8225;</span>Item 4</li>
        <li class="ui-widget-content"><span class="sort-handle">&#8225;</span>Item 5</li>
        <li class="ui-widget-content"><span class="sort-handle">&#8225;</span>Item 6</li>
        <li class="ui-widget-content"><span class="sort-handle">&#8225;</span>Item 7</li>
        <li class="ui-widget-content"><span class="sort-handle">&#8225;</span>Item 8</li>
        <li class="ui-widget-content"><span class="sort-handle">&#8225;</span>Item 9</li>
        <li class="ui-widget-content"><span class="sort-handle">&#8225;</span>Item 10</li>
    </ul>

    <script>
        $(function() {
            $('#list').selectable({
                cancel: '.sort-handle'
            }).sortable({
                items: "> li",
                handle: '.sort-handle',
                helper: function(e, item) {
                    if ( ! item.hasClass('ui-selected') ) {
                        item.parent().children('.ui-selected').removeClass('ui-selected');
                        item.addClass('ui-selected');
                    }

                    var selected = item.parent().children('.ui-selected').clone();
                    item.data('multidrag', selected).siblings('.ui-selected').remove();
                    return $('<li/>').append(selected);
                },
                stop: function(e, ui) {
                    var selected = ui.item.data('multidrag');
                    ui.item.after(selected);
                    ui.item.remove();
                }
            });
        });
    </script>
</body>