0
Iはそれぞれドラッグアンドドロップした後AJAX経由でJQuery UIでソートされたテーブルの注文を送信するには?
<table id="sort" class="grid">
<thead>
<tr><th>Permanent ID</th><th class="index">Sorted</th><th>Rest of the row</th></tr>
</thead>
<tbody>
<tr><th>63</th><td class="index"></td><td>something</td></tr>
<tr><th>65</th><td class="index"></td><td>test</td></tr>
<tr><th>11</th><td class="index"></td><td>more text</td></tr>
<tr><th>333</th><td class="index"></td><td>other stuff</td></tr>
<tr><th>2</th><td class="index"></td><td>something text</td></tr>
</tbody>
とJS
var fixHelperModified = function(e, tr) {
var $originals = tr.children();
var $helper = tr.clone();
$helper.children().each(function(index) {
$(this).width($originals.eq(index).width())
});
return $helper;
},
updateIndex = function(e, ui) {
$('td.index', ui.item.parent()).each(function (i) {
$(this).html(i + 1);
});
};
$("#sort tbody").sortable({
helper: fixHelperModified,
stop: updateIndex
}).disableSelection();
(jsfiddle)としてjQueryのUIを介して、テーブルの行の順序は、第二カラム(class="index"
)が新しい順に更新されます。この新しい行番号を取得してAJAX経由でサーバーに送信するにはどうすればよいですか?
実際、各ドラッグアンドドロップ操作後にAJAX経由で"Permanent ID"="Sorted"
の配列を送信する必要があります。
@All、それはあなたのために働いていますか? –