Koha/koha-tmpl/intranet-tmpl/prog/js/vue/composables/datatables.js
Jonathan Druart c036f58eeb
Bug 32030: Use composable for DT destroy
Use the Composition API to have this destroy code in a single place.

Signed-off-by: Jonathan Field <jonathan.field@ptfs-europe.com>

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-08 09:44:15 -03:00

11 lines
278 B
JavaScript

import { onBeforeUnmount } from "vue";
export function useDataTable(table_id) {
onBeforeUnmount(() => {
if ($.fn.DataTable.isDataTable("#" + table_id)) {
$("#" + table_id)
.DataTable()
.destroy(true);
}
});
}