ソースを参照

Fix #970: click and dblclick bug on no-rows table.

zhixin 10 年 前
コミット
8d50803862
1 ファイル変更4 行追加3 行削除
  1. 4 3
      src/bootstrap-table.js

+ 4 - 3
src/bootstrap-table.js

@@ -1428,7 +1428,7 @@
         }
         }
 
 
         // click to select by column
         // click to select by column
-        this.$body.find('> tr > td').off('click').on('click', function () {
+        this.$body.find('> tr[data-index] > td').off('click').on('click', function () {
             var $td = $(this),
             var $td = $(this),
                 $tr = $td.parent(),
                 $tr = $td.parent(),
                 item = that.data[$tr.data('index')],
                 item = that.data[$tr.data('index')],
@@ -1436,6 +1436,7 @@
                 $headerCell = that.$header.find('th:eq(' + cellIndex + ')'),
                 $headerCell = that.$header.find('th:eq(' + cellIndex + ')'),
                 field = $headerCell.data('field'),
                 field = $headerCell.data('field'),
                 value = item[field];
                 value = item[field];
+
             that.trigger('click-cell', field, value, item, $td);
             that.trigger('click-cell', field, value, item, $td);
             that.trigger('click-row', item, $tr);
             that.trigger('click-row', item, $tr);
             // if click to select - then trigger the checkbox/radio click
             // if click to select - then trigger the checkbox/radio click
@@ -1446,7 +1447,7 @@
                 }
                 }
             }
             }
         });
         });
-        this.$body.find('> tr > td').off('dblclick').on('dblclick', function () {
+        this.$body.find('> tr[data-index] > td').off('dblclick').on('dblclick', function () {
             var $td = $(this),
             var $td = $(this),
                 $tr = $td.parent(),
                 $tr = $td.parent(),
                 item = that.data[$tr.data('index')],
                 item = that.data[$tr.data('index')],
@@ -1458,7 +1459,7 @@
             that.trigger('dbl-click-row', item, $tr);
             that.trigger('dbl-click-row', item, $tr);
         });
         });
 
 
-        this.$body.find('> tr > td > .detail-icon').off('click').on('click', function () {
+        this.$body.find('> tr[data-index] > td > .detail-icon').off('click').on('click', function () {
             var $this = $(this),
             var $this = $(this),
                 $tr = $this.parent().parent(),
                 $tr = $this.parent().parent(),
                 index = $tr.data('index'),
                 index = $tr.data('index'),