微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jQuery可以在表上进行序列化排序

我有一张桌子:

<table class="products">
    <thead>...</thead>
    <tfoot>...</tfoot>

    <tbody id="the-list">
      <tr id="order-0">
        <th scope="row" class="check-column">stuff</th>
        <td class="title column-title">stuff</td>
        <td class="order column-order">stuff</td>
        <td class="display column-display">stuff</td>
        <td class="action column-action">stuff</td>
      </tr>
      <tr id="order-1">
        <th scope="row" class="check-column">stuff</th>
        <td class="title column-title">stuff</td>
        <td class="order column-order">stuff</td>
        <td class="display column-display">stuff</td>
        <td class="action column-action">stuff</td>
      </tr>
      <tr id="order-2">
        <th scope="row" class="check-column">stuff</th>
        <td class="title column-title">stuff</td>
        <td class="order column-order">stuff</td>
        <td class="display column-display">stuff</td>
        <td class="action column-action">stuff</td>
      </tr>
    </tbody>
</table>

当我使用“sortable”和认的一切时,一切都很好:

jQuery('table.products tbody').sortable();

现在,当我尝试序列化时,所有可排序的功能都会消失,表格是静态的(尽管……但没有错误)

jQuery('table.products tbody').sortable('serialize');

我做错了什么?

解决方法

从您的问题来看,您似乎没有在尝试使用其中的方法之前初始化您的插件.

您必须首先使用.sortable()初始化插件,然后您可以调用.sortable(‘serialize’)之类的方法.

var $table = jQuery('table.products tbody');

$table.sortable();
$table.sortable('serialize');

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐