Honus Wagner
Honus Wagner

Reputation: 2908

jQuery sortable with serialize on a table

I have a table:

<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>

When I use "sortable" with default everything, all is well:

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

now when I try to serialize, all sortable functionality disappears and the table is static (no errors though...)

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

What did I do wrong?

Upvotes: 4

Views: 5259

Answers (1)

Didier Ghys
Didier Ghys

Reputation: 30666

From your question, it seems you don't initialize your plugin prior to trying to use a method from it.

You have to first init the plugin with .sortable() and then you can call methods like .sortable('serialize').

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

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

Upvotes: 5

Related Questions