diff options
Diffstat (limited to 'uploader/static/js')
-rw-r--r-- | uploader/static/js/datatables.js | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/uploader/static/js/datatables.js b/uploader/static/js/datatables.js index 586ef30..76b1877 100644 --- a/uploader/static/js/datatables.js +++ b/uploader/static/js/datatables.js @@ -1,18 +1,25 @@ /** Handlers for events in datatables **/ -$(() => { - $("#tbl-phenotypes-list").on("draw.dt", () => { +var dtAddRowSelectionHandler = (tableId) => { + $(tableId).on("draw.dt", (event) => { $(".chk-row-select").on("change", (event) => { - var checkbox = event.target; - var tablerow = checkbox.parentElement.parentElement; + var checkboxOrRadio = event.target; + var tablerow = checkboxOrRadio.parentElement.parentElement; var tableclass = tablerow.getAttribute("class"); - if(checkbox.checked) { + if(checkboxOrRadio.checked) { + if (checkboxOrRadio.type == "radio") { + $(tableId + " tr").each((index, row) => { + var rowKlass = $(row).attr("class") || ""; + row.setAttribute( + "class", rowKlass.replaceAll("selected", "").trim()); + }); + } tablerow.setAttribute("class", `${tableclass} selected`); } else { tablerow.setAttribute( - "class", tableclass.replace("selected", "").trim()); + "class", tableclass.replaceAll("selected", "").trim()); } }); }); -}); +}; |