diff options
author | zsloan | 2020-12-03 14:08:36 -0600 |
---|---|---|
committer | zsloan | 2020-12-03 14:08:36 -0600 |
commit | f90ae0eb938b48a6467223d44816d9b6522280cf (patch) | |
tree | 61a573129c7dd56c6a408ad9345b9c10c78b2fe3 | |
parent | fabb29b6f47c11d3a1eeeb4cb94c8362e282dca3 (diff) | |
download | genenetwork2-f90ae0eb938b48a6467223d44816d9b6522280cf.tar.gz |
Fixed select_all and deselect_all to use DataTables API so they work with any tables that use Scroller
-rw-r--r-- | wqflask/wqflask/static/new/javascript/search_results.js | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/wqflask/wqflask/static/new/javascript/search_results.js b/wqflask/wqflask/static/new/javascript/search_results.js index 27d89867..3319d2cb 100644 --- a/wqflask/wqflask/static/new/javascript/search_results.js +++ b/wqflask/wqflask/static/new/javascript/search_results.js @@ -3,22 +3,31 @@ $(function() { checked_traits = null; select_all = function() { - console.log("selected_all"); - $(".trait_checkbox").each(function() { - $(this).prop('checked', true); - if (!$(this).closest('tr').hasClass('selected')) { - $(this).closest('tr').addClass('selected') - } - }); + table_api = $('#trait_table').DataTable(); + + check_cells = table_api.column(0).nodes().to$(); + for (let i = 0; i < check_cells.length; i++) { + check_cells[i].childNodes[0].checked = true; + } + + check_rows = table_api.rows().nodes(); + for (let i =0; i < check_rows.length; i++) { + check_rows[i].classList.add("selected") + } }; deselect_all = function() { - $(".trait_checkbox").each(function() { - $(this).prop('checked', false); - if ($(this).closest('tr').hasClass('selected')) { - $(this).closest('tr').removeClass('selected') - } - }); + table_api = $('#trait_table').DataTable(); + + check_cells = table_api.column(0).nodes().to$(); + for (let i = 0; i < check_cells.length; i++) { + check_cells[i].childNodes[0].checked = false; + } + + check_rows = table_api.rows().nodes(); + for (let i =0; i < check_rows.length; i++) { + check_rows[i].classList.remove("selected") + } }; invert = function() { |