diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js index e596764902..9d36b4799f 100644 --- a/InvenTree/templates/js/translated/order.js +++ b/InvenTree/templates/js/translated/order.js @@ -1153,7 +1153,36 @@ function showAllocationSubTable(index, row, element, options) { // Is the parent SalesOrder pending? var pending = options.status == {{ SalesOrderStatus.PENDING }}; + // Function to reload the allocation table + function reloadTable() { + table.bootstrapTable('refresh'); + } + + function setupCallbacks() { + // Add callbacks for 'edit' buttons + table.find('.button-allocation-edit').click(function() { + + var pk = $(this).attr('pk'); + + // TODO: Migrate to API forms + launchModalForm(`/order/sales-order/allocation/${pk}/edit/`, { + success: reloadTable, + }); + }); + + // Add callbacks for 'delete' buttons + table.find(".button-allocation-delete").click(function() { + var pk = $(this).attr('pk'); + + // TODO: Migrate to API forms + launchModalForm(`/order/sales-order/allocation/${pk}/delete/`, { + success: reloadTable, + }); + }); + } + table.bootstrapTable({ + onPostBody: setupCallbacks, data: row.allocations, showHeader: false, columns: [ @@ -1214,27 +1243,6 @@ function showAllocationSubTable(index, row, element, options) { }, ], }); - - // Add callbacks for 'edit' buttons - table.find(".button-allocation-edit").click(function() { - - var pk = $(this).attr('pk'); - - // TODO: Migrate to API forms - launchModalForm(`/order/sales-order/allocation/${pk}/edit/`, { - success: reloadTable, - }); - }); - - // Add callbacks for 'delete' buttons - table.find(".button-allocation-delete").click(function() { - var pk = $(this).attr('pk'); - - // TODO: Migrate to API forms - launchModalForm(`/order/sales-order/allocation/${pk}/delete/`, { - success: reloadTable, - }); - }); } /**