jQuery对表行排序失败

jQuery Sortable on table rows fail to move

本文关键字:排序 失败 jQuery      更新时间:2023-09-26

我试图使用jQuery可排序代码能够让客户排序他们的表行。然而,正如本文所示,除了之外的所有操作(拖放行)都会发生。我遵循了Sortable网站上的示例中的所有内容,包括检查后端代码,但它似乎仍然失败。

jQuery代码
$('.sorted_table').sortable({
    containerSelector: 'table',
    itemPath: '> tbody',
    itemSelector: 'tr',
    placeholder: '<tr class="placeholder"/>'
  });

CSS代码

body.dragging, body.dragging * {
    cursor: move !important;
}
.dragged {
    position: absolute;
    opacity: 0.5;
    z-index: 2000;
}
.sorted_table tr {
    cursor: pointer;
}
.sorted_table tr.placeholder {
    display: block;
    background: red;
    position: relative;
    margin: 0;
    padding: 0;
    border: none;
}
.sorted_table tr.placeholder:before {
    content:"";
    position: absolute;
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-left-color: red;
    margin-top: -5px;
    left: -5px;
    border-right: none;
}

这个问题需要关闭,但这是一个用户错误,未能将jQuery包含到JSFiddle库中。