From 4cba412e312ef989dd5701a061c6638ed959d4f4 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Thu, 17 Oct 2019 16:44:15 +0200 Subject: [PATCH] Fix protocols table select all checkbox [SCI-3999] --- app/assets/javascripts/protocols/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/protocols/index.js b/app/assets/javascripts/protocols/index.js index 789c63637..2f7b01387 100644 --- a/app/assets/javascripts/protocols/index.js +++ b/app/assets/javascripts/protocols/index.js @@ -12,7 +12,6 @@ var repositoryType; function init() { updateButtons(); initProtocolsTable(); - initRowSelection(); initKeywordFiltering(); initProtocolPreviewModal(); initLinkedChildrenModal(); @@ -99,6 +98,7 @@ function initProtocolsTable() { }, fnDrawCallback: function(settings, json) { animateSpinner(this, false); + initRowSelection(); $.initTooltips(); }, preDrawCallback: function(settings) { @@ -129,6 +129,8 @@ function initProtocolsTable() { } function initRowSelection() { + let protocolsTableScrollHead = protocolsTableEl.closest('.dataTables_scroll').find('.dataTables_scrollHead'); + // Handle click on table cells with checkboxes protocolsTableEl.on("click", "tbody td, thead th:first-child", function(e) { $(this).parent().find("input[type='checkbox']").trigger("click"); @@ -164,11 +166,11 @@ function initRowSelection() { }); // Handle click on "Select all" control - protocolsTableEl.find("thead input[name='select_all']").on("click", function(e) { + protocolsTableScrollHead.find("thead input[name='select_all']").on('click', function(e) { if (this.checked) { - protocolsTableEl.find("tbody input[type='checkbox']:not(:checked)").trigger("click"); + protocolsTableEl.find("tbody input[type='checkbox']:not(:checked)").trigger('click'); } else { - protocolsTableEl.find("tbody input[type='checkbox']:checked").trigger("click"); + protocolsTableEl.find("tbody input[type='checkbox']:checked").trigger('click'); } // Prevent click event from propagating to parent