jquery-ui - jQuery UI 可按固定行排序

标签 jquery-ui jquery-selectors jquery-ui-sortable

我正在使用可通过表格排序的 jQuery UI(工作正常)。我想让标题和最后一行固定(不可移动)。

jQuery UI 文档表明这可以使用项目选择器来完成,但我对语法感到困惑。

相关代码如下:

<script type="text/javascript">
    $(function () {
    $("#response_options tbody.content").sortable();
    $("#response_options tbody.content").disableSelection();
});
</script>

<table id="response_options" class="data-table">
    <tbody class="content">
        <tr>
            <th>Links</th><th>Response</th>
        </tr>
        <tr class="sortable-row">
           <td>Edit</td>
           <td>Item 1</td>
        </tr>
        <tr class="sortable-row">
            <td>Edit</td>
            <td>Item 2</td>
        </tr>
        <tr class="sortable-row">
            <td>Edit</td>
            <td>Item 3</td>
        </tr>
        <tr class="sortable-row">
            <td>Edit</td>
            <td>Item 4</td>
        </tr>
        <tr class="sortable-row">
            <td>Edit</td>
            <td>Item 5</td>
        </tr>
        <tr>
            <td>Edit</td>
            <td>Item 1</td>
        </tr>
    </tbody>
</table>

选择器进入.sortable(...):

$("#response_options tbody.content").sortable();

作为

$("#response_options tbody.content").sortable( items: ??? );

并且应该可以仅选择 class="sortable-row"的项目;但我再次对语法感到困惑。

最佳答案

这应该有效:

$("#response_options tbody.content").sortable({items: 'tr.sortable-row'});

关于jquery-ui - jQuery UI 可按固定行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5999613/

相关文章:

javascript - 根据CSS选择子元素

javascript - jQuery 实时处理程序但对于每个()?

javascript - 帮助 jQuery 字符串格式化

javascript - Jquery UI datepicker setDate 不适用于 formatDate 的动态更改

javascript - jQuery UI 日期选择器输入类

javascript - 在动态列表源的 jQuery 自动完成中突出显示查询

javascript - jQuery:如何选择 "from here until the next H2"?

javascript - 关闭后如何在 jquery 中重新打开模态对话框?

javascript - 在可排序的 JQuery UI 列表中至少保留一项

jquery - 在排序更改事件期间更新排序顺序 - jQuery UI