javascript - 拖放错误

标签 javascript jquery css

更新:找到这张关于错误的票证 http://bugs.jqueryui.com/ticket/5718 .我尝试了 position:absolute 但它破坏了 html 上的数据

我已经在我的应用程序中实现了拖放操作来对数据进行排序。拖动数据时,它必须与其他数据对齐。但在下图中。

enter image description here

请注意,当我拖动 Internet 时,它会位于顶部。

拖动时必须与他人对齐。如何解决这个问题?有没有办法让数据在拖动时必须在光标中,而不是在顶部?

下面是拖放代码:

 <script>
    var addPositions = function() {
        $('.dropenv, .dropcat').each(function() {
            var position = 0;
            $(this).children().each(function() {
                $(this).data('position', position);
                position++;
            });
        });
    };

    $(document).ready(function() {
        addPositions();

        $(".dropenv").sortable({
            connectWith: "tbody.env-data",
            dropOnEmpty: true,
            handle: '.env-handle',
            start: function(event, ui) {
                parentID = ui.item.parent().siblings('tr').attr('id');
            },
            stop: function(event, ui) {
                datas = new Array();
                var i = 0;

                ui.item.closest('tbody').children('tr').each(function() {
                    datas[i] = $(this).attr('id');
                    i++;
                });

                $.ajax({
                    type: "POST",
                    data: { 
                        'cat_id': parentID,
                        'env[]': datas, 
                        'csrfmiddlewaretoken': '{{ csrf_token }}'
                    }, 
                    url:"/envelopes/sort/",
                    contentType: "application/json;charset=utf-8",
                    dataType: "json",
                    success: function(data) { 
                        notify('', data, { autoClose: true, delay: 1000 });
                    },
                    error: function(ts) { 
                        notify('', ts.responseText, { autoClose: true, delay: 1000 });
                    }
                });
            }
        });

        $( ".dropcat").sortable({
            connectWith: "tbody.cat-data",
            dropOnEmpty: true,
            handle: '.cat-handle',
            update: function(){
                datas = new Array();
                var i = 0;

                $('.dropcat tr.masterList').each(function() {
                    datas[i] = $(this).attr('id');
                    i++;
                });

                $.ajax({
                    type: "POST",
                    data: { 
                        'cat[]': datas, 
                        'csrfmiddlewaretoken': '{{ csrf_token }}'
                    }, 
                    url:"/envelopes/categories/sort/",
                    contentType: "application/json;charset=utf-8",
                    dataType: "json",
                    success: function(data) { 
                        notify('', data, { autoClose: true, delay: 1000 });
                    },
                    error: function(ts) { 
                        notify('', ts.responseText, { autoClose: true, delay: 1000 });
                    }
                });
            }
        });
    });
    </script>

最佳答案

找到答案:overflow:auto

<table class="simple-table responsive-table" style="overflow:auto">

关于javascript - 拖放错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15432538/

相关文章:

javascript - 从 JavaScript 更改样式不保存

javascript - 在客户端查找调用的javascript函数

javascript - 用于在 Safari 中打开弹出窗口的 jquery 对话框

javascript - 格式化 JS 生成的文本?

javascript - 在 angularJs 中返回请求响应

jquery - 拖放 : changing the background

jquery - jQuery 有没有办法选择属性名称为 "data-*"的所有元素

css - 相对(父)内容下的自动高度文本内容

javascript - 从另一个文件分配特定文本以弹出显示 html

javascript - 我可以在不调用对象函数的情况下获得(可能是计算出的)属性值吗?