简体   繁体   English

jQuery UI中的FROM和TO占位符:可排序

[英]FROM and TO Placeholders in JQuery UI : Sortable

I am trying to make the list items (cards) sortable, but for usability improvements I want to show the user an placeholder on the old (with text "FROM") and one on the new (with text "TO") before user releases mouse (ends .sortable). 我正在尝试使列表项(卡)可排序,但是为了提高可用性,我想在用户发布之前向用户展示一个占位符(旧的占位符(文本为“ FROM”),新的占位符(占位文本“ TO”)。鼠标(结尾为.sortable)。

helper: 'clone',
placeholder: {
    element: function(currentItem) {
        return $('<li class="placeholder">FROM or TO</li>')[0];
    },
    update: function(container, p) {
        return;
    },
}

right above, you see what I have for now, but is it possible to split "FROM" and "TO"? 在右上方,您会看到我现在所拥有的,但是可以将“ FROM”和“ TO”分开吗?

I made it myself. 我自己做的。 Was quite complicated to introduce a second "placeholder" on old position. 在旧职位上引入第二个“占位符”非常复杂。 See here: 看这里:

If you move an li, you now have an "FROM"-Container at old-pos and and "TO"-Container on future-pos, wich will be removed after positioning. 如果您移动一个li,则现在在old-pos上有一个“ FROM”-容器,而在future-pos上有一个“ TO”-容器,将在定位后移除。

    $(function() {
    var oldList, newList, item;
    $(".selector").sortable({
        start: function(event, ui) {
            item = ui.item;
            newList = oldList = ui.item.parent().parent();
            var activeElem = item.index();
            $(this).children().eq(activeElem).after('<li class="placeholder">From</li>');
        },
        stop: function(event, ui) {
            //alert("Moved " + item.text() + " from " + oldList.attr('id') + " to " + newList.attr('id'));
            $(".selector > li").remove(".placeholder");
        },
        change: function(event, ui) {
            if(ui.sender) newList = ui.placeholder.parent().parent();
        },
        connectWith: ".selector",
        helper: 'clone',
        placeholder: {
            element: function(currentItem) {
                return $('<li class="placeholder">To</li>')[0];
            },
            update: function(container, p) {
                return;
            }
        }
    }).disableSelection();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM