浏览代码

添加监听表格滚动事件

添加监听表格滚动事件
theScoreONE 8 年之前
父节点
当前提交
d51fc72ae6
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      src/bootstrap-table.js

+ 7 - 1
src/bootstrap-table.js

@@ -448,6 +448,9 @@
         },
         onResetView: function () {
             return false;
+        },
+        onScrollBody: function () {
+            return false;
         }
     };
 
@@ -547,7 +550,8 @@
         'collapse-row.bs.table': 'onCollapseRow',
         'refresh-options.bs.table': 'onRefreshOptions',
         'reset-view.bs.table': 'onResetView',
-        'refresh.bs.table': 'onRefresh'
+        'refresh.bs.table': 'onRefresh',
+        'scroll-body.bs.table': 'onScrollBody'
     };
 
     BootstrapTable.prototype.init = function () {
@@ -2291,6 +2295,8 @@
         var that = this;
         // horizontal scroll event
         // TODO: it's probably better improving the layout than binding to scroll event
+
+        that.trigger('scroll-body');
         this.$tableBody.off('scroll').on('scroll', function () {
             if (that.options.showHeader && that.options.height) {
               that.$tableHeader.scrollLeft($(this).scrollLeft());