Skip to content

Commit

Permalink
bug with table sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
smariel committed Aug 24, 2018
1 parent b3cbb8d commit 4e8d6f1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions js/obj.PartListEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,24 @@ PartListEditor.prototype.refresh = function() {
});

// sort the table
this.sortTable(0);
this.sortTable();
};


// sort the part table
PartListEditor.prototype.sortTable = function(col) {
// init sort direction
let dir = 'asc';
let toggle = true;

if(undefined === col) {
col = 0;
toggle = false;
}

// if th clicked th is already sorted
let th_elt = $(`thead > .tr_bottom > th:nth-child(${col+1})`);
if(th_elt.hasClass('sort')) {
if(toggle && th_elt.hasClass('sort')) {
// toggle direction
th_elt.toggleClass('sortAsc sortDesc');
if(th_elt.hasClass('sortDesc')) dir = 'desc';
Expand Down

0 comments on commit 4e8d6f1

Please sign in to comment.