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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user