Simplify adding rows to sortable tables

The `append` method can handle arrays, so there's no need to loop
through each element.

There's more to improve on this method, like the `asc` variable being
global to a table instead of depending on the current column, but for
now I'm only refactoring and maintaining the current behaviour.
This commit is contained in:
Javi Martín
2019-06-29 15:33:40 +02:00
parent 4d7c124188
commit 936aa7af0f

View File

@@ -13,10 +13,10 @@ App.TableSortable =
table = $(this).parents("table").eq(0)
rows = table.find("tr:gt(0)").not("tfoot tr").toArray().sort(App.TableSortable.comparer($(this).index()))
@asc = !@asc
if !@asc
rows = rows.reverse()
i = 0
while i < rows.length
table.append rows[i]
i++
if @asc
table.append rows
else
table.append rows.reverse()
return