only add the default sorter once.

This commit is contained in:
DESKTOP-T0O5CDB\DESK-555BD 2025-01-21 15:57:50 -07:00
parent 2bf2469657
commit a4f15ffe15
2 changed files with 11 additions and 7 deletions

View File

@ -279,9 +279,11 @@ function sortGarage(sender, isMobile) {
sender.addClass('sort-asc');
sender.html(isMobile ? `<span class="ms-2 display-3">${garageIcon}${sortColumn}${sortAscIcon}</span>` : `${garageIcon}${sortColumn}${sortAscIcon}`);
//append sortRowId to the vehicle container
$(`.garage-item`).map((index, elem) => {
$(elem).attr("default-sort", index);
});
if ($("[default-sort]").length == 0) {
$(`.garage-item`).map((index, elem) => {
$(elem).attr("default-sort", index);
});
}
sortVehicles(false);
}
}

View File

@ -446,10 +446,12 @@ function toggleSort(tabName, sender) {
}
sender.addClass('sort-asc');
sender.html(`${sortColumn}${sortAscIcon}`);
//append sortRowId to the table rows.
$(`#${tabName} table tbody tr`).map((index, elem) => {
$(elem).attr("default-sort", index);
});
//append sortRowId to the table rows if nothing has been appended yet.
if ($("[default-sort]").length == 0) {
$(`#${tabName} table tbody tr`).map((index, elem) => {
$(elem).attr("default-sort", index);
});
}
sortTable(tabName, sortColumn, false);
}
}