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/species.js | |
| parent | ef71af77671669531bbc07c7363511117b7d13e9 (diff) | |
| download | gn-uploader-cfa33d211372d40edcd35d2c0d74daf261fe6bf3.tar.gz | |
Extract common DataTables into a reusable function.
Diffstat (limited to 'uploader/static/js/species.js')
| -rw-r--r-- | uploader/static/js/species.js | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/uploader/static/js/species.js b/uploader/static/js/species.js index 1f2aa3b..c1374c6 100644 --- a/uploader/static/js/species.js +++ b/uploader/static/js/species.js @@ -1,19 +1,10 @@ -var speciesDataTable = (speciesdata) => { - var lengthMenu = [10, 25, 50, 100, 1000]; - if(speciesdata.length > 1000) { - lengthMenu.push(speciesdata.length) - } - $("#tbl-select-species").DataTable({ - responsive: true, - lengthMenu: lengthMenu, - language: { - processing: "Processing… Please wait.", - loadingRecords: "Loading species — Please wait.", - lengthMenu: "Show _MENU_ species", - info: "Showing _START_ to _END_ of _TOTAL_ species" - }, - data: speciesdata, - columns: [ +$(() => { + dtAddCommonHandlers("#tbl-select-species"); + var speciesDataTable = buildDataTable( + "#tbl-select-species", + JSON.parse( + $("#tbl-select-species").attr("data-species-list")), + [ { data: (aspecies) => { return `<input type="radio" name="species_id"` @@ -26,12 +17,5 @@ var speciesDataTable = (speciesdata) => { return `${aspecies.FullName} (${aspecies.SpeciesName})`; } } - ] - }); -}; - -$(() => { - dtAddCommonHandlers("#tbl-select-species"); - speciesDataTable(JSON.parse( - $("#tbl-select-species").attr("data-species-list"))); + ]); }); |
