$(function () {
var $tbody = $('#bomDetailTable tbody');
if (!$tbody.length) return;
$tbody.sortable({
handle: '.dragger',
helper: function (e, ui) {
ui.children().each(function () { $(this).width($(this).width()); });
return ui;
},
update: function () {
renumberBomRows();
// (Optional) send AJAX to persist immediately
// saveBomOrderAjax();
}
}).disableSelection();
function renumberBomRows() {
$('#bomDetailTable tbody tr').each(function (idx) {
var pos = idx + 1;
$(this).find('.order-cell').text(pos);
$(this).find('input.bom-order-input').val(pos);
});
}
});