diff options
author | Frederick Muriuki Muriithi | 2025-03-11 16:50:04 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-03-11 16:58:43 -0500 |
commit | cfa33d211372d40edcd35d2c0d74daf261fe6bf3 (patch) | |
tree | 9de7a84e4e87c693d7b54ca2ac4271e720313a7d /uploader/static/js/populations.js | |
parent | ef71af77671669531bbc07c7363511117b7d13e9 (diff) | |
download | gn-uploader-cfa33d211372d40edcd35d2c0d74daf261fe6bf3.tar.gz |
Extract common DataTables into a reusable function.
Diffstat (limited to 'uploader/static/js/populations.js')
-rw-r--r-- | uploader/static/js/populations.js | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/uploader/static/js/populations.js b/uploader/static/js/populations.js index 5c1f848..73e298a 100644 --- a/uploader/static/js/populations.js +++ b/uploader/static/js/populations.js @@ -1,19 +1,10 @@ -var populationDataTable = (populationdata) => { - var lengthMenu = [10, 25, 50, 100, 1000]; - if(populationdata.length > 1000) { - lengthMenu.push(populationdata.length) - } - $("#tbl-select-population").DataTable({ - responsive: true, - lengthMenu: lengthMenu, - language: { - processing: "Processing… Please wait.", - loadingRecords: "Loading population — Please wait.", - lengthMenu: "Show _MENU_ populations", - info: "Showing _START_ to _END_ of _TOTAL_ populations" - }, - data: populationdata, - columns: [ +$(() => { + dtAddCommonHandlers("#tbl-select-population"); + var populationsDataTable = buildDataTable( + "#tbl-select-population", + JSON.parse( + $("#tbl-select-population").attr("data-populations-list")), + [ { data: (apopulation) => { return `<input type="radio" name="population_id"` @@ -27,13 +18,5 @@ var populationDataTable = (populationdata) => { return `${apopulation.FullName} (${apopulation.InbredSetName})`; } } - ] - }); -}; - - -$(() => { - dtAddCommonHandlers("#tbl-select-population"); - populationDataTable(JSON.parse( - $("#tbl-select-population").attr("data-populations-list"))); + ]); }); |