浏览代码

Fix #29: sortOrder bug.

zhixin 11 年之前
父节点
当前提交
922e5cc2d6
共有 1 个文件被更改,包括 6 次插入2 次删除
  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);