......

JQuery sorted with serialization by 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 the default value, all is well:

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

now when i try to serialize, all sorting options disappear and the table is static (no errors ...)

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

What have I done wrong?

+4
source share
1 answer

From your question, it looks like you are not initializing your plugin before you try to use its method.

You must start the plugin with .sortable() , and then you can call methods like .sortable('serialize') .

 var $table = jQuery('table.products tbody'); $table.sortable(); $table.sortable('serialize'); 
+4
source

Source: https://habr.com/ru/post/1401661/


All Articles