Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow direction of sort to be specified

  • Loading branch information...
commit 1fc5ecbdab1285d935c2bdf63be22689da49c412 1 parent ce989cf
@kylefox authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 jquery.tablesort.js
View
10 jquery.tablesort.js
@@ -28,12 +28,11 @@ $(function() {
$.tablesort.prototype = {
- sort: function(th) {
+ sort: function(th, direction) {
var start = new Date(),
self = this,
table = this.$table,
rows = table.find('tbody tr'),
- direction,
aRow,
bRow,
aIndex,
@@ -47,7 +46,12 @@ $(function() {
this.index = th.index();
this.$th = th;
- this.direction = this.direction === 'asc' ? 'desc' : 'asc';
+
+ if(direction !== 'asc' && direction !== 'desc')
+ this.direction = this.direction === 'asc' ? 'desc' : 'asc';
+ else
+ this.direction = direction;
+
direction = this.direction == 'asc' ? 1 : -1;
self.$table.trigger('tablesort:start', [self]);

0 comments on commit 1fc5ecb

Please sign in to comment.
Something went wrong with that request. Please try again.