简体   繁体   English

jQuery-ui Draggable不适合可排序列表

[英]jQuery-ui draggable does not fit in sortable list

I have a sortable list and some draggable elements, which I created with jquery-ui. 我有一个可排序的列表和一些可拖动元素,它们是使用jquery-ui创建的。 I want to drag the draggable elements into the sortable list, so the are added in the last. 我想将可拖动元素拖动到可排序列表中,因此将它们添加到最后一个列表中。 I have used the "connectToSortable" option but nothing is happening when I drag the element over the sortable list.. Are there some kind of restrictions? 我使用了“ connectToSortable”选项,但是将元素拖到可排序列表上时什么也没发生。.是否存在某种限制?

The draggable element are the "td" of a table and the sortable elements are the "li" of a list. 可拖动元素是表的“ td”,可排序元素是列表的“ li”。

Check this DEMO out : http://jsfiddle.net/yeyene/7fEQs/203/ 检查此演示: http : //jsfiddle.net/yeyene/7fEQs/203/

I tried using draggable element are the "td" of a table and the sortable elements are the "li" of a list. 我尝试使用可拖动元素是表的“ td”,而可排序元素是列表的“ li”。

JQUERY JQUERY

$(function() {
    $( "#draggable td" ).draggable({
        connectToSortable: "#sortable",
        helper: "clone",
        revert: "invalid"
    });

    $( "#sortable" ).sortable({
        revert: true,
        receive: function(event, ui) {
            var html = [];
            $(this).find('td').each(function() {
                html.push('<li>'+$(this).html()+'</li>');
            });
            $(this).find('td').replaceWith(html.join(''));
        }
    });
});

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

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