diff options
Diffstat (limited to 'uploader')
-rw-r--r-- | uploader/static/js/datatables.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/uploader/static/js/datatables.js b/uploader/static/js/datatables.js index 76b1877..ff7a680 100644 --- a/uploader/static/js/datatables.js +++ b/uploader/static/js/datatables.js @@ -23,3 +23,29 @@ var dtAddRowSelectionHandler = (tableId) => { }); }); }; + + +var toggleCheck = (checkboxOrRadio) => { + if (checkboxOrRadio.length > 0) { + var currentState = checkboxOrRadio.prop("checked"); + var newState = !currentState; + if (currentState == true && checkboxOrRadio.attr("type").toLowerCase() == "radio") { + // We don't want to toggle from true to false by clicking on the row + // if it is a radio button. + newState = currentState; + } + checkboxOrRadio.prop("checked", newState); + checkboxOrRadio.trigger("change"); + } +}; + + +var dtAddRowClickHandler = (tableId) => { + $(tableId).on("draw.dt", (event) => { + $(tableId + " tbody tr").on("click", (event) => { + var row = event.target.closest("tr"); + var checkboxOrRadio = $(row).find(".chk-row-select"); + toggleCheck(checkboxOrRadio); + }); + }); +}; |