Browse Source

Fix #29: sortOrder bug.

zhixin 11 years ago
parent
commit
922e5cc2d6
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/bootstrap-table.js

+ 6 - 2
src/bootstrap-table.js

@@ -317,8 +317,12 @@
         var $this = $(event.currentTarget);
 
         this.$header.find('span.order').remove();
-        this.options.sortName = $this.data('field');
-        this.options.sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc';
+        if (this.options.sortName === $this.data('field')) {
+            this.options.sortOrder = this.options.sortOrder === 'asc' ? 'desc' : 'asc';
+        } else {
+            this.options.sortName = $this.data('field');
+            this.options.sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc';
+        }
         this.trigger('sort', this.options.sortName, this.options.sortOrder);
 
         $this.data('order', this.options.sortOrder);