2016-03-07 85 views

回答

1

我相信是scroll事件的結合,與類.fixed-table-body元素的問題,不存在,直到引導表有完成渲染。

爲了解決這個問題,在引導表的post標題事件觸發時綁定滾動事件。

$("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/

+0

你能告訴我你怎麼知道'post-header.bs.table'元素?無論如何謝謝師父! – andrefadila

+1

@andrefadila查看http://bootstrap-table.wenzhixin.net.cn/documentation/#events上的文檔中的事件我最初認爲它可能是post-body.bs.table事件,但事實證明標題是正確的。 – Valeklosse

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'); 
    } 
    }); 
}); 
+0

我知道這是@Valeklosse首先給出的想法之後的正確代碼。不管怎麼說,還是要謝謝你。 – andrefadila

+0

不客氣 –