私が使用: http://johnny.github.io/jquery-sortable/
このプラグインを使用すると、リストの順序またはテーブルの行の順序を変更できます (私の場合です)。たとえば、マウスで 4 行目を 2 番目の位置にドラッグします。新しい順序にアクセスできるプラグイン メソッドsort.sortable("serialize")の幅。
しかし、 sort.sortable("serialize") の使い方は?
ここに例があります: http://johnny.github.io/jquery-sortable/#table テーブル行の新しい順序を myurl.php に送信したいと思います。
sortable("serialize")を使用して$.post経由で新しい注文をPHP スクリプトに送信する方法は?
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:
// Initialize the plugin
var sort = $(".tablesort").sortable({
// After changing the order
onDrop: function ($item, container, _super) {
var myObject = sort.sortable("serialize");
// How to prepare *myObject* for sending?
$.post('myurl.php', {blah:myObject}, function(){});
});