From 3c4fe338b61b5de67e9edf070e5b02a79f4c0eba Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 3 May 2019 17:43:36 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B02192=20fix=20freeze=20when=20lots=20of?= =?UTF-8?q?=20lines=20in=20a=20table=20with=20selectable=20lines=20Many=20?= =?UTF-8?q?thanks=20to=20Jeffrey=20Bostoen=20(@jbostoen)=20for=20the=20bug?= =?UTF-8?q?=20report=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/jquery.tablesorter.pager.js | 4 ++-- js/table-selectable-lines.js | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/js/jquery.tablesorter.pager.js b/js/jquery.tablesorter.pager.js index 81e53c59d..b6e328c8d 100644 --- a/js/jquery.tablesorter.pager.js +++ b/js/jquery.tablesorter.pager.js @@ -285,9 +285,9 @@ function sprintf(format, etc) { } }); - $(table).find(':checkbox[name^=selectObj]').change(function() { + $(table).find(':checkbox[name^=selectObj]').on("change init-selection", function () { storeSelection(table, table.config.container, this.value, this.checked, this.disabled); - }).trigger("change"); + }).trigger("init-selection"); // don't need to trigger the very generic change event ! } else if (table.config.select_mode == 'single') { diff --git a/js/table-selectable-lines.js b/js/table-selectable-lines.js index 21f81e858..f9ecf7ada 100644 --- a/js/table-selectable-lines.js +++ b/js/table-selectable-lines.js @@ -59,8 +59,14 @@ $(document).ready(function () { $lineClickedInput.click(); }); - $(document).on('change', TABLE_SELECTOR+':has('+LINE_WITH_INPUT_IN_FIRST_CELL_SELECTOR+')', function (event) { + $(document).on('change', 'table.listResults', function (event) { var $eventTarget = $(event.target); + if (!$eventTarget.has(LINE_WITH_INPUT_IN_FIRST_CELL_SELECTOR)) + // Originally we had :has in the handler selector but performances were very bad :( + // Filtering directly in JQuery is far much quicker ! => N°2192 + { + return; + } if (!$eventTarget.is(INPUT_SELECTOR)) { return; } @@ -105,8 +111,9 @@ $(document).ready(function () { function updateLines($inputChanged) { var $selectedLine = $inputChanged.closest("tr"); - if ($inputChanged.is('input:radio')) { - // didn't find a proper event fired when radio is deselected... so doing this ! + // didn't find a proper event fired when radio is deselected... so doing this ! + if ($inputChanged.is('input:radio')) + { $selectedLine .closest('table') .find('tr')