Bootstrap表溢出事件

时间:2016-03-07 07:31:47

标签: jquery twitter-bootstrap

根据我之前的问题: How to detect table that have overflow when reach bottom [jQuery]

我为使用溢出样式(前端不好)的表重新设计UI而变得疯狂。这个引导程序示例为我提供了良好的UI,但是当找到底行时,我还没有找到检测滚动事件的元素。

示例:http://jsfiddle.net/andrefadila/vbcwbz5m/2/

$('.fixed-table-body').on('scroll', function () {
    if ($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) {
        alert('end reached');
    }
})

提前致谢

2 个答案:

答案 0 :(得分:1)

我认为问题是滚动事件的绑定,因为具有类.fixed-table-body的元素在引导表完成呈现之前不存在。

要解决此问题,请在引导表的post标头事件触发时绑定scroll事件。

$("table").on("post-header.bs.table",function() {
    $("#console").append("<div>hello</div>");

    $('.fixed-table-body').unbind().on("scroll", function () {
        $("#console").append("<div>hello</div>");
    });
});

http://jsfiddle.net/v0c4rtnf/9/

答案 1 :(得分:0)

尝试使用下面的jquery它会帮助你。

$("table").on("post-header.bs.table",function() {
$('.fixed-table-body').on("scroll", function () {
    if($(this).scrollTop() + $(this).innerHeight()>=$(this)[0].scrollHeight)
    {
      alert('end reached');
    }
  });
});