I use: http://johnny.imtqy.com/jquery-sortable/
With this plugin, you can change the order of the list or the row order of the table (this is my case). For example, using the mouse, you drag the fourth row to the second position. The width of the plugin method sort.sortable ("serialize") . You have access to a new order.
But how to use sort.sortable ("serialize") ?
Here you will find an example: http://johnny.imtqy.com/jquery-sortable/#table
I would like to send a new row order for the myurl.php table.
How to use sort ("serialize") to send a new order using $. post on php script?
HTML:
<table class="tablesort">
<tbody>
<tr data-id="39"><td>item 1</td></tr>
<tr data-id="37"><td>item 2</td></tr>
<tr data-id="40"><td>item 3</td></tr>
<tr data-id="61"><td>item 4</td></tr>
</tbody>
</table>
JavaScript:
var sort = $(".tablesort").sortable({
onDrop: function ($item, container, _super) {
var myObject = sort.sortable("serialize");
$.post('myurl.php', {blah:myObject}, function(){});
});
source
share