N°2192 fix freeze when lots of lines in a table with selectable lines

Many thanks to Jeffrey Bostoen (@jbostoen) for the bug report !
This commit is contained in:
Pierre Goiffon
2019-05-03 17:43:36 +02:00
parent 6159ab33b7
commit 3c4fe338b6
2 changed files with 12 additions and 5 deletions

View File

@@ -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')
{

View File

@@ -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')