From 322721877511ad7271ed3779017174cfc74ef4d8 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 3 Dec 2020 17:10:28 -0600 Subject: Fixed drawCallback for correlation page table and added the Invert button --- wqflask/wqflask/templates/correlation_page.html | 52 +++++++------------------ 1 file changed, 15 insertions(+), 37 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 0e623cbb..aa74abf5 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -75,6 +75,7 @@
+ @@ -256,41 +257,6 @@ {% endif %} $(document).ready( function () { - - $('#trait_table tr').click(function(event) { - if (event.target.type !== 'checkbox') { - $(':checkbox', this).trigger('click'); - } - }); - - function change_buttons() { - buttons = ["#add", "#remove"]; - num_checked = $('.trait_checkbox:checked').length; - if (num_checked === 0) { - for (_i = 0, _len = buttons.length; _i < _len; _i++) { - button = buttons[_i]; - $(button).prop("disabled", true); - } - } else { - for (_j = 0, _len2 = buttons.length; _j < _len2; _j++) { - button = buttons[_j]; - $(button).prop("disabled", false); - } - } - if ($(this).is(":checked")) { - if (!$(this).closest('tr').hasClass('selected')) { - $(this).closest('tr').addClass('selected') - } - } - else { - if ($(this).closest('tr').hasClass('selected')) { - $(this).closest('tr').removeClass('selected') - } - } - } - - console.time("Creating table"); - table_conf = { buttons: [ { @@ -305,6 +271,20 @@ postfixButtons: [ 'colvisRestore' ] } ], + 'drawCallback': function( settings ) { + $('#trait_table tr').off().on("click", function(event) { + if (event.target.type !== 'checkbox' && event.target.tagName.toLowerCase() !== 'a') { + var obj =$(this).find('input'); + obj.prop('checked', !obj.is(':checked')); + } + if ($(this).hasClass("selected")){ + $(this).removeClass("selected") + } else { + $(this).addClass("selected") + } + }); + $('.trait_checkbox:checkbox').on("change", change_buttons); + }, "data": table_json, "columns": [ { @@ -570,8 +550,6 @@ } ); } ).draw(); - console.timeEnd("Creating table"); - $('.toggle-vis').on('click', function (e) { e.preventDefault(); -- cgit v1.2.3